User:Nicole Hametner/canvas: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
See also [[Canvas]]. | |||
A basic coding control structure is the loop which takes it's simplest form as: | |||
while CONDITION { | |||
LOOP | |||
LOOP | |||
while( | LOOP... | ||
} | |||
The condition should be some kind of "boolean" expression that is "true" for a while, and eventually "false" when the loop should stop running. | |||
<canvas id="c1" showsrc> | |||
function draw(){ | |||
p. | c = document.getElementById("c1") | ||
//console.log("c is",c) | |||
p = c.getContext("2d") | |||
x = 10 | |||
while (x<250) { | |||
p.strokeRect(x,100,20,40) | |||
x+=60 | |||
} | |||
} | } | ||
</ | </canvas> | ||
Revision as of 16:02, 14 October 2012
See also Canvas.
A basic coding control structure is the loop which takes it's simplest form as:
while CONDITION { LOOP LOOP LOOP... }
The condition should be some kind of "boolean" expression that is "true" for a while, and eventually "false" when the loop should stop running.
<canvas id="c1" showsrc> function draw(){
c = document.getElementById("c1") //console.log("c is",c) p = c.getContext("2d") x = 10 while (x<250) { p.strokeRect(x,100,20,40) x+=60 }
} </canvas>