Mercurial > MadButterfly
comparison nodejs/testcase.js @ 778:61c217f8cec8
Fix bug of transformation from user space to image space.
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Mon, 30 Aug 2010 13:07:49 +0800 |
parents | cceac4ba259e |
children | 9367508842b2 |
comparison
equal
deleted
inserted
replaced
777:72b5bb88979f | 778:61c217f8cec8 |
---|---|
20 /* Testcase for image shapes */ | 20 /* Testcase for image shapes */ |
21 var img = mb_rt.image_new(10, 10, 50, 50); | 21 var img = mb_rt.image_new(10, 10, 50, 50); |
22 var ldr = mbfly.img_ldr_new("."); | 22 var ldr = mbfly.img_ldr_new("."); |
23 var img_data = ldr.load("sample.png"); | 23 var img_data = ldr.load("sample.png"); |
24 var paint = mb_rt.paint_image_new(img_data); | 24 var paint = mb_rt.paint_image_new(img_data); |
25 var img_coord = mb_rt.coord_new(root); | |
25 paint.fill(img); | 26 paint.fill(img); |
26 root.add_shape(img); | 27 img_coord.add_shape(img); |
27 | 28 |
28 /* test linear paint and rectangle */ | 29 /* test linear paint and rectangle */ |
29 var rect = mb_rt.rect_new(100, 100, 50, 50, 10, 10); | 30 var rect = mb_rt.rect_new(100, 100, 50, 50, 10, 10); |
30 sys.puts(mb_rt.paint_linear_new); | 31 sys.puts(mb_rt.paint_linear_new); |
31 var paint = mb_rt.paint_linear_new(100, 100, 150, 150); | 32 var paint = mb_rt.paint_linear_new(100, 100, 150, 150); |
141 paint.set_color(c, 1, 1, 1); | 142 paint.set_color(c, 1, 1, 1); |
142 mb_rt.redraw_changed(); | 143 mb_rt.redraw_changed(); |
143 mb_rt.flush(); | 144 mb_rt.flush(); |
144 }); | 145 }); |
145 | 146 |
147 var resize_sw = 0; | |
148 setInterval(function() { | |
149 var sz; | |
150 | |
151 resize_sw++; | |
152 | |
153 sz = (resize_sw % 20) - 10; | |
154 if(sz < 0) | |
155 sz = -sz; | |
156 sz = 2 - sz / 10; | |
157 | |
158 img_coord[0] = sz; | |
159 img_coord[4] = sz; | |
160 mb_rt.redraw_changed(); | |
161 mb_rt.flush(); | |
162 }, 50); | |
163 | |
146 var kbobserver; | 164 var kbobserver; |
147 /* Keyboard event */ | 165 /* Keyboard event */ |
148 kbobserver = mb_rt.kbevents.add_event_observer(6, function(evt) { | 166 kbobserver = mb_rt.kbevents.add_event_observer(6, function(evt) { |
149 sys.puts("keycode = " + evt.keycode); | 167 sys.puts("keycode = " + evt.keycode); |
150 sys.puts("sym = " + evt.sym); | 168 sys.puts("sym = " + evt.sym); |