commit-bot@chromium.org | 48d94b8c | 2013-12-16 18:24:51 +0000 | [diff] [blame] | 1 | /** |
| 2 | * @fileoverview Sample onDraw script for use with SkV8Example. |
| 3 | */ |
| 4 | var onDraw = function(){ |
| 5 | var tick = 0; |
jcgregorio | 5e44b00 | 2014-10-27 10:27:01 -0700 | [diff] [blame] | 6 | var p = new Path2D(); |
| 7 | p.rect(0, 0, 200, 200); |
| 8 | |
commit-bot@chromium.org | c8d7328 | 2014-01-06 18:17:24 +0000 | [diff] [blame] | 9 | function f(context) { |
commit-bot@chromium.org | 0fc0dea | 2013-12-18 04:45:37 +0000 | [diff] [blame] | 10 | tick += 0.1; |
jcgregorio | 5e44b00 | 2014-10-27 10:27:01 -0700 | [diff] [blame] | 11 | |
| 12 | context.translate(context.width/2, context.height/2); |
| 13 | context.rotate(tick); |
| 14 | context.drawPath(p); |
commit-bot@chromium.org | 48d94b8c | 2013-12-16 18:24:51 +0000 | [diff] [blame] | 15 | }; |
| 16 | return f; |
| 17 | }(); |
commit-bot@chromium.org | 0fc0dea | 2013-12-18 04:45:37 +0000 | [diff] [blame] | 18 | |
| 19 | function onTimeout() { |
| 20 | inval(); |
commit-bot@chromium.org | 872796b | 2013-12-20 15:56:52 +0000 | [diff] [blame] | 21 | print(setTimeout(onTimeout, 33)); |
commit-bot@chromium.org | 0fc0dea | 2013-12-18 04:45:37 +0000 | [diff] [blame] | 22 | } |
| 23 | |
| 24 | setTimeout(onTimeout, 33); |