Skip to content

Instantly share code, notes, and snippets.

@nataliefreed
Created October 1, 2014 22:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nataliefreed/01adba6fdf3c5fb4ddf1 to your computer and use it in GitHub Desktop.
Save nataliefreed/01adba6fdf3c5fb4ddf1 to your computer and use it in GitHub Desktop.
//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