1 # Copyright (C) 2002-2004 Kouichirou Eto, All rights reserved.
2 # StrokeFont library by eto 2003-0311
13 # @hsv = [0, 0, 100] #白
19 def init() @start_time = Time.now; end
21 def set_strokes(strokes)
27 return if @strokes.nil?
28 @strokes.strokes.each_with_index {|stroke, index|
29 #draw_delay(stroke, index)
30 draw_alpha(stroke, 100)
34 def draw_alpha(stroke, time)
38 stroke.points.each {|x, y|
40 colorHSV(@hsv[0], @hsv[1], @hsv[2], a*100.0)
41 line(px, py, x, y) if (px != 0 || py != 0) #最初の点ではない
47 def draw_delay(stroke, index)
49 @start_time = Time.now if @start_time == nil
50 diff = now - @start_time #開始からの秒数がはいる
51 draw_alpha(stroke, diff - index*0.3)
55 class Stroke # a connected line
67 return @length if @length
72 len += Math.sqrt((x-px)*(x-px)+(y-py)*(y-py))
84 @px1, @py1, @px2, @py2 = 0, 0, 0, 0
85 @x1, @y1, @x2, @y2 = 0, 0, 0, 0
90 def add_line(x1, y1, x2, y2)
91 if (@px != x1 || @py != y1) #以前の点とつながっていなかったら、
92 @strokes << Stroke.new
93 @strokes.last.add_point(x1, y1)
95 @strokes.last.add_point(x2, y2)