Sha256: 0386a3df39478582a33e3c0014f5bef4eceeede959e9ec678ea1d4c8f21db664

Contents?: true

Size: 962 Bytes

Versions: 22

Compression:

Stored size: 962 Bytes

Contents

# -*- coding: utf-8 -*-
# gradation.rb
#
# gradation.rb: 文字列をグラデーション表示
#   パラメタ:
#     str:         文字列
#     first_color: グラデーション開始色(16進 6桁指定)
#     last_color:  グラデーション終了色(16進 6桁指定)
#
# Copyright (c) 2002 TADA Tadashi <sho@spc.gr.jp>
# You can distribute this file under the GPL2.
#
def gradation( str, first_color, last_color )
	ary = str.split( //u )
	len = ary.length - 1
	result = ""
	r = first_color[0..1].hex.to_f
	g = first_color[2..3].hex.to_f
	b = first_color[4..5].hex.to_f
	rd = ((last_color[0..1].hex - r)/len)
	gd = ((last_color[2..3].hex - g)/len)
	bd = ((last_color[4..5].hex - b)/len)
	ary.each do |x|
		c = sprintf( '%02x%02x%02x', r, g, b )
		result << %Q[<span style="color: ##{c}">#{h x}</span>]
		r += rd
		g += gd
		b += bd
	end
	result
end


# Local Variables:
# mode: ruby
# indent-tabs-mode: t
# tab-width: 3
# ruby-indent-level: 3
# End:

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
tdiary-4.0.5.1 misc/plugin/gradation.rb
tdiary-4.0.5 misc/plugin/gradation.rb
tdiary-4.0.4 misc/plugin/gradation.rb
tdiary-4.0.3 misc/plugin/gradation.rb
tdiary-4.0.2.20140201 misc/plugin/gradation.rb
tdiary-4.0.2 misc/plugin/gradation.rb
tdiary-4.0.1.20131102 misc/plugin/gradation.rb
tdiary-4.0.1.20130929 misc/plugin/gradation.rb
tdiary-4.0.1.20130903 misc/plugin/gradation.rb
tdiary-4.0.1 misc/plugin/gradation.rb
tdiary-4.0.0.20130826 misc/plugin/gradation.rb
tdiary-4.0.0 misc/plugin/gradation.rb
tdiary-3.2.2.20130727 misc/plugin/gradation.rb
tdiary-3.2.2.20130722 misc/plugin/gradation.rb
tdiary-3.2.2.20130720 misc/plugin/gradation.rb
tdiary-3.2.2.20130617 misc/plugin/gradation.rb
tdiary-3.2.2.20130614 misc/plugin/gradation.rb
tdiary-3.2.2.20130604 misc/plugin/gradation.rb
tdiary-3.2.2.20130527 misc/plugin/gradation.rb
tdiary-3.2.2.20130518 misc/plugin/gradation.rb