Mercurial > MadButterfly
comparison nodejs/testcase.js @ 699:0b98bdc53215
Add binding for color changing of paint_color_t in JS
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Wed, 11 Aug 2010 17:38:44 +0800 |
parents | 6ddc8b42188f |
children | d950487bd9f9 |
comparison
equal
deleted
inserted
replaced
698:32e1b8005403 | 699:0b98bdc53215 |
---|---|
8 sys.puts("root matrix: " + | 8 sys.puts("root matrix: " + |
9 [root[0], root[1], root[2], root[3], root[4], root[5]]); | 9 [root[0], root[1], root[2], root[3], root[4], root[5]]); |
10 var coord = mb_rt.coord_new(root); | 10 var coord = mb_rt.coord_new(root); |
11 sys.puts("coord matrix: " + | 11 sys.puts("coord matrix: " + |
12 [coord[0], coord[1], coord[2], coord[3], coord[4], coord[5]]); | 12 [coord[0], coord[1], coord[2], coord[3], coord[4], coord[5]]); |
13 sys.puts('coord='+coord); | |
14 | 13 |
15 /* Testcase for image shapes */ | 14 /* Testcase for image shapes */ |
16 var img = mb_rt.image_new(10, 10, 50, 50); | 15 var img = mb_rt.image_new(10, 10, 50, 50); |
17 var ldr = mbfly.img_ldr_new("."); | 16 var ldr = mbfly.img_ldr_new("."); |
18 var img_data = ldr.load("sample.png"); | 17 var img_data = ldr.load("sample.png"); |
53 mb_rt.redraw_all(); | 52 mb_rt.redraw_all(); |
54 | 53 |
55 var i = 0; | 54 var i = 0; |
56 setInterval(function() { | 55 setInterval(function() { |
57 var deg = (i++) * 0.1; | 56 var deg = (i++) * 0.1; |
58 coord[2] = (i % 20) * 10; | 57 coord[2] = (i % 40) * 5; |
59 mb_rt.redraw_changed(); | 58 mb_rt.redraw_changed(); |
60 mb_rt.flush(); | 59 mb_rt.flush(); |
61 }, 20); | 60 }, 20); |
62 setTimeout(function() { sys.puts("timeout"); }, 1000); | 61 setTimeout(function() { sys.puts("timeout"); }, 1000); |
63 | 62 |
64 sys.puts(root.mouse_event); | 63 sys.puts(root.mouse_event); |
65 var observer; | 64 var observer; |
66 /* Mouse button pressed */ | 65 /* Mouse button pressed */ |
67 observer = root.mouse_event.add_event_observer(4, function(evt) { | 66 observer = root.mouse_event.add_event_observer(4, function(evt) { |
67 var c = 1 - (i % 40) / 40; | |
68 sys.puts(c); | |
69 | |
68 sys.puts("mouse " + evt.x + " " + evt.y); | 70 sys.puts("mouse " + evt.x + " " + evt.y); |
71 sys.puts(c); | |
72 sys.puts(paint.set_color); | |
73 paint.set_color(c, 1, 1, 1); | |
74 mb_rt.redraw_changed(); | |
75 mb_rt.flush(); | |
69 }); | 76 }); |
70 | 77 |
71 var kbobserver; | 78 var kbobserver; |
72 /* Keyboard event */ | 79 /* Keyboard event */ |
73 kbobserver = mb_rt.kbevents.add_event_observer(6, function(evt) { | 80 kbobserver = mb_rt.kbevents.add_event_observer(6, function(evt) { |