Created
February 14, 2014 03:29
-
-
Save chaserx/8995296 to your computer and use it in GitHub Desktop.
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
// 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