Skip to content

Instantly share code, notes, and snippets.

@chaserx
Created February 14, 2014 03:29
Show Gist options
  • Save chaserx/8995296 to your computer and use it in GitHub Desktop.
Save chaserx/8995296 to your computer and use it in GitHub Desktop.
// Random Heart
// random hearts for you
int number = 128;
float x;
float y;
float a;
// http://www.colourlovers.com/palette/1099931/be_my_valentine
color[] palette = { color(247,162,185), color(242,100,122), color(221,38,32), color(146,2,0) };
// from: http://forum.processing.org/two/discussion/1748/repeat-shapesimgs-in-random-places/p1
void setup() {
background(255);
size(400, 400);
strokeWeight(5);
imageMode(CENTER);
for (int i = 0; i < number; i++) {
x = random(width);
y = random(height);
a = random(359);
pushMatrix();
translate(x, y);
rotate(a);
draw_heart();
popMatrix();
}
save("hearts.tif");
}
// from: http://processing.org/discourse/beta/num_1246205739.html
// and: http://www.processing.org/discourse/beta/num_1273287759.html
void draw_heart() {
for (int i = 0; i < 255; ++i) {
int j = int(random(4));
int k = int(random(4));
int temp = palette[j];
palette[j] = palette[k];
palette[k] = temp;
}
smooth();
noStroke();
fill(palette[0]);
beginShape();
vertex(50, 15);
bezierVertex(50, -5, 90, 5, 50, 40);
vertex(50, 15);
bezierVertex(50, -5, 10, 5, 50, 40);
endShape();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment