1c8d732800e1a660fca6d2478fc24d6e6935ef8adcommit-bot@chromium.org/** 2c8d732800e1a660fca6d2478fc24d6e6935ef8adcommit-bot@chromium.org * @fileoverview Sample onDraw script for use with SkV8Example. 3c8d732800e1a660fca6d2478fc24d6e6935ef8adcommit-bot@chromium.org */ 4c8d732800e1a660fca6d2478fc24d6e6935ef8adcommit-bot@chromium.orgvar onDraw = function(){ 5f679d1bf38a9e319c2b38fa53852f05b7f246e8ecommit-bot@chromium.org var p = new Path2D(); 6c8d732800e1a660fca6d2478fc24d6e6935ef8adcommit-bot@chromium.org p.moveTo(0, 0); 7c8d732800e1a660fca6d2478fc24d6e6935ef8adcommit-bot@chromium.org p.bezierCurveTo(0, 100, 100, 0, 200, 200); 8c8d732800e1a660fca6d2478fc24d6e6935ef8adcommit-bot@chromium.org p.close(); 9c8d732800e1a660fca6d2478fc24d6e6935ef8adcommit-bot@chromium.org p.moveTo(0, 300); 10c8d732800e1a660fca6d2478fc24d6e6935ef8adcommit-bot@chromium.org p.arc(0, 300, 40, Math.PI/2, 3/2*Math.PI); 11c8d732800e1a660fca6d2478fc24d6e6935ef8adcommit-bot@chromium.org function f(context) { 12c8d732800e1a660fca6d2478fc24d6e6935ef8adcommit-bot@chromium.org context.translate(10, 10); 13c8d732800e1a660fca6d2478fc24d6e6935ef8adcommit-bot@chromium.org for (var i=0; i<256; i++) { 14d7841047e2a9360eedf077fa7a47c7b800692632commit-bot@chromium.org context.strokeStyle = '#0000' + toHex(i); 15c8d732800e1a660fca6d2478fc24d6e6935ef8adcommit-bot@chromium.org context.stroke(p); 16c8d732800e1a660fca6d2478fc24d6e6935ef8adcommit-bot@chromium.org context.translate(1, 0); 17c8d732800e1a660fca6d2478fc24d6e6935ef8adcommit-bot@chromium.org } 18c8d732800e1a660fca6d2478fc24d6e6935ef8adcommit-bot@chromium.org context.fillStyle = '#ff0000'; 19c8d732800e1a660fca6d2478fc24d6e6935ef8adcommit-bot@chromium.org print(context.width, context.height); 20c8d732800e1a660fca6d2478fc24d6e6935ef8adcommit-bot@chromium.org context.resetTransform(); 21c8d732800e1a660fca6d2478fc24d6e6935ef8adcommit-bot@chromium.org context.fillRect(context.width/2, context.height/2, 20, 20); 22c8d732800e1a660fca6d2478fc24d6e6935ef8adcommit-bot@chromium.org }; 23c8d732800e1a660fca6d2478fc24d6e6935ef8adcommit-bot@chromium.org return f; 24c8d732800e1a660fca6d2478fc24d6e6935ef8adcommit-bot@chromium.org}(); 25c8d732800e1a660fca6d2478fc24d6e6935ef8adcommit-bot@chromium.org 26c8d732800e1a660fca6d2478fc24d6e6935ef8adcommit-bot@chromium.org 27c8d732800e1a660fca6d2478fc24d6e6935ef8adcommit-bot@chromium.orgfunction toHex(n) { 28c8d732800e1a660fca6d2478fc24d6e6935ef8adcommit-bot@chromium.org var s = n.toString(16); 29c8d732800e1a660fca6d2478fc24d6e6935ef8adcommit-bot@chromium.org if (s.length == 1) { 30c8d732800e1a660fca6d2478fc24d6e6935ef8adcommit-bot@chromium.org s = "0" + s; 31c8d732800e1a660fca6d2478fc24d6e6935ef8adcommit-bot@chromium.org } 32c8d732800e1a660fca6d2478fc24d6e6935ef8adcommit-bot@chromium.org return s; 33c8d732800e1a660fca6d2478fc24d6e6935ef8adcommit-bot@chromium.org} 34