2014-01-06 18:17:24 +00:00
|
|
|
/**
|
|
|
|
* @fileoverview Sample onDraw script for use with SkV8Example.
|
|
|
|
*/
|
|
|
|
var onDraw = function(){
|
2014-02-27 20:20:21 +00:00
|
|
|
var p = new Path2D();
|
2014-01-06 18:17:24 +00:00
|
|
|
p.moveTo(0, 0);
|
|
|
|
p.bezierCurveTo(0, 100, 100, 0, 200, 200);
|
|
|
|
p.close();
|
|
|
|
p.moveTo(0, 300);
|
|
|
|
p.arc(0, 300, 40, Math.PI/2, 3/2*Math.PI);
|
|
|
|
function f(context) {
|
|
|
|
context.translate(10, 10);
|
|
|
|
for (var i=0; i<256; i++) {
|
2014-01-07 19:00:27 +00:00
|
|
|
context.strokeStyle = '#0000' + toHex(i);
|
2014-01-06 18:17:24 +00:00
|
|
|
context.stroke(p);
|
|
|
|
context.translate(1, 0);
|
|
|
|
}
|
|
|
|
context.fillStyle = '#ff0000';
|
|
|
|
print(context.width, context.height);
|
|
|
|
context.resetTransform();
|
|
|
|
context.fillRect(context.width/2, context.height/2, 20, 20);
|
|
|
|
};
|
|
|
|
return f;
|
|
|
|
}();
|
|
|
|
|
|
|
|
|
|
|
|
function toHex(n) {
|
|
|
|
var s = n.toString(16);
|
|
|
|
if (s.length == 1) {
|
|
|
|
s = "0" + s;
|
|
|
|
}
|
|
|
|
return s;
|
|
|
|
}
|