File: gradient.rb

package info (click to toggle)
tdiary 2.0.2%2B20060303-5
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 8,172 kB
  • ctags: 1,957
  • sloc: ruby: 23,926; lisp: 514; makefile: 87; sh: 71; sql: 32
file content (28 lines) | stat: -rw-r--r-- 760 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# gradient.rb $Revision: 1.1.4.1 $
#
# gradient.rb: ʸ礭Ѳʤɽ
#   ѥ᥿:
#     str:        ʸ
#     first_size: ʸ(͡ñpt)
#     last_size:  ʸ(͡ñpt)
#
#   : ֤ʤȤǤޤפ10pt30pt˳
#     <%=gradient 'ʤȤǤޤ', 10, 30 %>
#
# Copyright (C) 2002 by TADA Tadashi <sho@spc.gr.jp>
# You can redistribute it and/or modify it under GPL2.
#
def gradient( str, first_size, last_size )
	ary = str.split( // )
	len = ary.length - 1
	result = ""
	fontsize = first_size.to_f
	sd = ( last_size - first_size ).to_f / len
	ary.each do |x|
		s = sprintf( '%d',fontsize.round )
		result << %Q[<span style="font-size: #{s}pt;">#{x}</span>]
		fontsize += sd
	end
	result
end