1 # Copyright (C) 2002-2004 Kouichirou Eto, All rights reserved.
2 # StrokeFont library by eto 2003-0311
5 $LOAD_PATH << "../../lib" if $0 == __FILE__
14 # @hsv = [0, 0, 100] #白
20 def init() @start_time = Time.now; end
22 def set_strokes(strokes)
28 return if @strokes.nil?
29 @strokes.strokes.each_with_index {|stroke, index|
30 #draw_delay(stroke, index)
31 draw_alpha(stroke, 100)
35 def draw_alpha(stroke, time)
39 stroke.points.each {|x, y|
41 colorHSV(@hsv[0], @hsv[1], @hsv[2], a*100.0)
42 line(px, py, x, y) if (px != 0 || py != 0) #最初の点ではない
48 def draw_delay(stroke, index)
50 @start_time = Time.now if @start_time == nil
51 diff = now - @start_time #開始からの秒数がはいる
52 draw_alpha(stroke, diff - index*0.3)
56 class Stroke #====================================================== 一本の線
68 return @length if @length
73 len += Math.sqrt((x-px)*(x-px)+(y-py)*(y-py))
82 class Strokes #===================================================== 複数の線
85 @px1, @py1, @px2, @py2 = 0, 0, 0, 0
86 @x1, @y1, @x2, @y2 = 0, 0, 0, 0
91 def add_line(x1, y1, x2, y2)
92 if (@px != x1 || @py != y1) #以前の点とつながっていなかったら、
93 @strokes << Stroke.new
94 @strokes.last.add_point(x1, y1)
96 @strokes.last.add_point(x2, y2)