update.
[chise/ruby.git] / chise / codeviewer.rb
index 0c70df4..3e8fc57 100755 (executable)
@@ -1,11 +1,12 @@
 # Copyright (C) 2002-2004 Kouichirou Eto, All rights reserved.
 
-require "stroke"
+require "chise/stroke"
 
 module StrokeFont
   class CodeViewer
     WIDTH, HEIGHT = 256, 256
     SCALE = 2
+
     def initialize(cx=0, cy=0)
       @cx, @cy = cx, cy
       @s = SCALE
@@ -19,6 +20,7 @@ module StrokeFont
       calc_code
     end
     attr_reader :code
+
     def draw
       colorHSV(0, 0, 100, 10) #まずは下敷きになる枠を書きます。
       rect(@x1, @y1, @x2, @y2)
@@ -34,6 +36,7 @@ module StrokeFont
       line(@px-@pw/2, @py, @px+@pw/2, @py)
       line(@px, @py-@ph/2, @px, @py+@ph/2)
     end
+
     def onMouse(x, y)
       if @onkeydown
        x, y = @px, @py
@@ -50,6 +53,7 @@ module StrokeFont
        return false
       end
     end
+
     def calc_code()
       x = ((@px - @x1)/@s).to_i
       y = HEIGHT-1 - ((@py - @y1)/@s).to_i
@@ -63,6 +67,7 @@ module StrokeFont
        return false
       end
     end
+
     def show_list(list)
       colorHSV(0, 100, 100, 100)
       list.each {|code|
@@ -70,6 +75,7 @@ module StrokeFont
        rect(x, y, x+2, y-2)
       }
     end
+
     def code_to_xy(code)
       cx = code % WIDTH
       cy = HEIGHT - (code / WIDTH) #intになる?
@@ -77,13 +83,17 @@ module StrokeFont
       y = cy * SCALE + @y1
       return x, y
     end
+
     def length(x, y)    Math.sqrt(x*x + y*y)  end
+
     def onMouseDown(x, y)
       if length(@px-x, @py-y) < @pr
        @dragging = true
       end
     end
+
     def onMouseUp(x, y)    @dragging = false  end
+
     def onKeyDown(key)
       @onkeydown = true
       case key