1 # Copyright (C) 2002-2004 Kouichirou Eto, All rights reserved.
7 WIDTH, HEIGHT = 256, 256
9 def initialize(cx=0, cy=0)
12 @x1, @y1 = @cx-@s*WIDTH/2, @cy-@s*HEIGHT/2
13 @x2, @y2 = @cx+@s*WIDTH/2, @cy+@s*HEIGHT/2
14 @px, @py = @cx, @cy #とりあえず中心が開始点
15 @pw, @ph, @pr = 30, 30, 10
23 colorHSV(0, 0, 100, 10) #まずは下敷きになる枠を書きます。
24 rect(@x1, @y1, @x2, @y2)
26 colorHSV(0, 0, 100, 50)
29 line(@x1, @y1+n*s, @x2, @y1+n*s)
30 line(@x1+n*s, @y1, @x1+n*s, @y2)
32 colorHSV(0, 100, 100, 100) # 次にポインターを書きます
34 line(@px-@pw/2, @py, @px+@pw/2, @py)
35 line(@px, @py-@ph/2, @px, @py+@ph/2)
41 if @dragging || @onkeydown
43 @px, @py = x, y #p [x, y]
44 @px = @x1 if @px < @x1
45 @py = @y1 if @py < @y1
46 @px = @x2-1 if @x2-1 < @px
47 @py = @y2-1 if @y2-1 < @py
54 x = ((@px - @x1)/@s).to_i
55 y = HEIGHT-1 - ((@py - @y1)/@s).to_i
61 printf("%02x %02x %04x\n", x, y, @code)
67 colorHSV(0, 100, 100, 100)
69 x, y = code_to_xy(code)
75 cy = HEIGHT - (code / WIDTH) #intになる?
80 def length(x, y) Math.sqrt(x*x + y*y) end
82 if length(@px-x, @py-y) < @pr
86 def onMouseUp(x, y) @dragging = false end
104 $LOAD_PATH << "../../src"
107 require "chise/stroke"
112 window(-300,-300,300,300)
116 @csf1 = CSFFont.new() #普通の文字
117 @csf2 = CSFFont.new(CSF_KOUKOTSU_FILE) #甲骨文字
119 @kage = KageFont.new()
124 @changed = @cs.onMouse(mouseX, mouseY) #変化があったか?
126 @cs.show_list(@kage.cache_list)
139 char = Character.get(code)
141 @kage.init(code) if @changed
142 @kage.print(code) if @changed
147 char = Character.get(ucs)
149 j = char.japanese_jisx0208
152 csf = @key == 1 ? @csf1 : @csf2
153 csf.init(code) if @changed
154 csf.print(code) if @changed
158 def onMouseDown(x, y) @cs.onMouseDown(x, y)end
159 def onMouseUp(x, y) @cs.onMouseUp(x, y)end