skia2/experimental/SkV8Example/js/sample.js

30 lines
527 B
JavaScript
Raw Normal View History

/**
* @fileoverview Sample onDraw script for use with SkV8Example.
*/
var onDraw = function(){
var ticks = 0;
var b = new Path2DBuilder();
b.rect(0, 0, 200, 200);
var p = b.finalize();
function f(context) {
ticks += 1;
context.translate(context.width/2, context.height/2);
context.rotate(ticks/10);
context.drawPath(p);
inval();
};
function onTimeout() {
console.log(ticks);
ticks = 0;
setTimeout(onTimeout, 1000);
}
setTimeout(onTimeout, 1000);
return f;
}();