f679d1bf38
BUG=skia: R=robertphillips@google.com Author: jcgregorio@google.com Review URL: https://codereview.chromium.org/177963005 git-svn-id: http://skia.googlecode.com/svn/trunk@13615 2bbb7eff-a529-9590-31e7-b0007b416f81
34 lines
823 B
JavaScript
34 lines
823 B
JavaScript
/**
|
|
* @fileoverview Sample onDraw script for use with SkV8Example.
|
|
*/
|
|
var onDraw = function(){
|
|
var p = new Path2D();
|
|
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++) {
|
|
context.strokeStyle = '#0000' + toHex(i);
|
|
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;
|
|
}
|