blob: f04da337e2a4d52880f4668770bec9d010a61714 [file] [log] [blame]
commit-bot@chromium.org48d94b8c2013-12-16 18:24:51 +00001/**
2 * @fileoverview Sample onDraw script for use with SkV8Example.
3 */
4var onDraw = function(){
jcgregorioe001da22014-10-29 05:33:27 -07005 var ticks = 0;
6 var b = new Path2DBuilder();
7 b.rect(0, 0, 200, 200);
8 var p = b.finalize();
jcgregorio5e44b002014-10-27 10:27:01 -07009
commit-bot@chromium.orgc8d73282014-01-06 18:17:24 +000010 function f(context) {
jcgregorioe001da22014-10-29 05:33:27 -070011 ticks += 1;
jcgregorio5e44b002014-10-27 10:27:01 -070012
13 context.translate(context.width/2, context.height/2);
jcgregorioe001da22014-10-29 05:33:27 -070014 context.rotate(ticks/10);
jcgregorio5e44b002014-10-27 10:27:01 -070015 context.drawPath(p);
jcgregorioe001da22014-10-29 05:33:27 -070016
17 inval();
commit-bot@chromium.org48d94b8c2013-12-16 18:24:51 +000018 };
jcgregorioe001da22014-10-29 05:33:27 -070019
20 function onTimeout() {
21 console.log(ticks);
22 ticks = 0;
23 setTimeout(onTimeout, 1000);
24 }
25 setTimeout(onTimeout, 1000);
26
commit-bot@chromium.org48d94b8c2013-12-16 18:24:51 +000027 return f;
28}();
commit-bot@chromium.org0fc0dea2013-12-18 04:45:37 +000029