blob: 81eb0d772bf3cd1237a6d697617464cd4130914e [file] [log] [blame]
commit-bot@chromium.orgc8d73282014-01-06 18:17:24 +00001/**
2 * @fileoverview Sample onDraw script for use with SkV8Example.
3 */
4var onDraw = function(){
commit-bot@chromium.orgf679d1b2014-02-27 20:20:21 +00005 var p = new Path2D();
commit-bot@chromium.orgc8d73282014-01-06 18:17:24 +00006 p.moveTo(0, 0);
7 p.bezierCurveTo(0, 100, 100, 0, 200, 200);
8 p.close();
9 p.moveTo(0, 300);
10 p.arc(0, 300, 40, Math.PI/2, 3/2*Math.PI);
11 function f(context) {
12 context.translate(10, 10);
13 for (var i=0; i<256; i++) {
commit-bot@chromium.orgd7841042014-01-07 19:00:27 +000014 context.strokeStyle = '#0000' + toHex(i);
commit-bot@chromium.orgc8d73282014-01-06 18:17:24 +000015 context.stroke(p);
16 context.translate(1, 0);
17 }
18 context.fillStyle = '#ff0000';
19 print(context.width, context.height);
20 context.resetTransform();
21 context.fillRect(context.width/2, context.height/2, 20, 20);
commit-bot@chromium.orgc8d73282014-01-06 18:17:24 +000022 };
23 return f;
24}();
25
26
27function toHex(n) {
28 var s = n.toString(16);
29 if (s.length == 1) {
30 s = "0" + s;
31 }
32 return s;
33}