Created
October 2, 2015 15:17
-
-
Save chrisallick/d2ae35b6c0f63666460d to your computer and use it in GitHub Desktop.
Shapes with Loops
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function setup() { | |
createCanvas(640, 480); | |
// use anti-aliasing | |
smooth(); | |
// no stroke on my shapes | |
noStroke(); | |
/* | |
use upper left corner | |
not the center | |
*/ | |
ellipseMode( CORNER ); | |
// just run the draw cycle 1 time :) | |
noLoop(); | |
} | |
function draw() { | |
var x = 20; | |
while( x < 200 ) { | |
console.log( "[example 3] value of x: " + x ); | |
fill( random(0,255), random(0,255), random(0,255) ); | |
ellipse( x, 20, 20, 20 ); | |
x = x + 30; | |
} | |
x = 20; | |
for( var i = 0; i < 6; i++ ) { | |
console.log( "[example 3] value of x: " + x ); | |
fill( random(0,255), random(0,255), random(0,255) ); | |
rect( x, 60, 20, 20 ); | |
x = x + 30; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment