OLD | NEW |
1 /** | 1 /** |
2 * @fileoverview Sample onDraw script for use with SkV8Example. | 2 * @fileoverview Sample onDraw script for use with SkV8Example. |
3 */ | 3 */ |
4 var onDraw = function(){ | 4 var onDraw = function(){ |
5 var tick = 0; | 5 var tick = 0; |
| 6 var p = new Path2D(); |
| 7 p.rect(0, 0, 200, 200); |
| 8 |
6 function f(context) { | 9 function f(context) { |
7 tick += 0.1; | 10 tick += 0.1; |
8 context.fillStyle = '#0000ff'; | 11 |
9 context.fillRect(100, 100, Math.sin(tick)*100, Math.cos(tick)*100); | 12 context.translate(context.width/2, context.height/2); |
| 13 context.rotate(tick); |
| 14 context.drawPath(p); |
10 }; | 15 }; |
11 return f; | 16 return f; |
12 }(); | 17 }(); |
13 | 18 |
14 function onTimeout() { | 19 function onTimeout() { |
15 inval(); | 20 inval(); |
16 print(setTimeout(onTimeout, 33)); | 21 print(setTimeout(onTimeout, 33)); |
17 } | 22 } |
18 | 23 |
19 setTimeout(onTimeout, 33); | 24 setTimeout(onTimeout, 33); |
OLD | NEW |