Created
October 2, 2015 15:20
-
-
Save chrisallick/0cda48100367f5681024 to your computer and use it in GitHub Desktop.
Shapes with Loops & Functions
This file contains hidden or 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 makeEllipse( x ) { | |
| fill( random(0,255), random(0,255), random(0,255) ); | |
| ellipse( x, 20, 20, 20 ); | |
| } | |
| function makeRect( x ) { | |
| fill( random(0,255), random(0,255), random(0,255) ); | |
| rect( x, 60, 20, 20 ); | |
| } | |
| function draw() { | |
| var x = 20; | |
| for( var i = 0; i < 6; i++ ) { | |
| makeEllipse( x ); | |
| makeRect( x ); | |
| x = x + 30; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment