Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Side by Side Diff: experimental/SkV8Example/gears.js

Issue 141113002: Clear the canvas before drawing the gears. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 var IS_SKV8 = typeof document == "undefined"; 1 var IS_SKV8 = typeof document == "undefined";
2 var HAS_PATH = typeof Path != "undefined"; 2 var HAS_PATH = typeof Path != "undefined";
3 3
4 var NumTeeth = 24; 4 var NumTeeth = 24;
5 var NumGears = 60; 5 var NumGears = 60;
6 var DeltaTheta = Math.PI/90; 6 var DeltaTheta = Math.PI/90;
7 var FaceColors = ["#000099", "#006600", "#990000", "#EEEE00"]; 7 var FaceColors = ["#000099", "#006600", "#990000", "#EEEE00"];
8 var SideColors = ["#0000FF", "#009900", "#FF0000", "#CCCC00"]; 8 var SideColors = ["#0000FF", "#009900", "#FF0000", "#CCCC00"];
9 9
10 function makeGear(pathLike, r) { 10 function makeGear(pathLike, r) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 path: gearPath(r), 90 path: gearPath(r),
91 r: r, 91 r: r,
92 faceColor: FaceColors[color], 92 faceColor: FaceColors[color],
93 sideColor: SideColors[color] 93 sideColor: SideColors[color]
94 }); 94 });
95 } 95 }
96 96
97 function draw(ctx) { 97 function draw(ctx) {
98 ctx.resetTransform(); 98 ctx.resetTransform();
99 99
100 ctx.fillStyle = "#FFFFFF";
101 ctx.fillRect(0, 0, 499, 499);
102
100 rotation += DeltaTheta; 103 rotation += DeltaTheta;
101 if (rotation >= Math.PI*2) { 104 if (rotation >= Math.PI*2) {
102 rotation = 0; 105 rotation = 0;
103 } 106 }
104 107
105 for (var i=0; i < gears.length; i++) { 108 for (var i=0; i < gears.length; i++) {
106 gear = gears[i]; 109 gear = gears[i];
107 draw3DGearAt(ctx, rotation, gear); 110 draw3DGearAt(ctx, rotation, gear);
108 } 111 }
109 112
(...skipping 19 matching lines...) Expand all
129 var canvas = document.getElementById("gears"); 132 var canvas = document.getElementById("gears");
130 var ctx = canvas.getContext("2d"); 133 var ctx = canvas.getContext("2d");
131 function drawCallback() { 134 function drawCallback() {
132 onDraw(ctx); 135 onDraw(ctx);
133 setTimeout(drawCallback, 1); 136 setTimeout(drawCallback, 1);
134 } 137 }
135 setTimeout(drawCallback, 1); 138 setTimeout(drawCallback, 1);
136 } 139 }
137 } 140 }
138 141
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698