Created
October 1, 2014 22:53
-
-
Save nataliefreed/01adba6fdf3c5fb4ddf1 to your computer and use it in GitHub Desktop.
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
//generative rings of diamond shapes | |
//Natalie Freed Oct. 2014 | |
int numberOfDiamonds; //we will randomize this | |
float spacingX = 25; | |
float spacingY = 25; | |
float diamondWidth; //we will randomize this | |
float diamondHeight; //we will randomize this | |
void setup() | |
{ | |
size(500, 500); | |
} | |
void draw() | |
{ | |
background(255); | |
numberOfDiamonds = round(random(0, 50)); | |
diamondWidth = random(0, 50); | |
diamondHeight = random(0, 200); | |
translate(width/2, height/4); | |
for(int i=0;i<numberOfDiamonds;i++) | |
{ | |
translate(spacingX, spacingY); //space between diamonds | |
rotate(radians(360.0 / numberOfDiamonds)); | |
drawDiamond(diamondWidth, diamondHeight); | |
} | |
noLoop(); //stop repeating | |
} | |
void drawDiamond(float w, float h) | |
{ | |
beginShape(); | |
vertex(w/2, -h/2); | |
vertex(w, 0); | |
vertex(w/2, h/2); | |
vertex(0, 0); | |
endShape(CLOSE); | |
} | |
void mousePressed() | |
{ | |
redraw(); //call draw() even if it's not looping | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment