"Heart Attack": Purple+Colored Hearts Screensaver: Happy V-day for my beautiful wife.

  • Download Gist
purple_colored_hearts_vday_screensaver.pde
Processing
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
// Purple Hearts Screensaver
// "Heart Attack"
// Happy V-day
// For my beautiful wife
// By Nicholas 'Ape-Inago' Perry aka UltimApe
// contact: ape.inago@gmail.com
// Released Creative Commons 3.0 License: share-alike, remix and commercial rights
// License available online: https://creativecommons.org/licenses/by-sa/3.0/deed.en_US
 
int circlewidth= 50; // not used right now
float scalevalue = 1;
float scalefactor = 1.01; // Used as a multiplier for the heart size
int colorcode = 1; // A flag variable for registering what 'pass' we are in for coloring of the hearts.
 
void setup () {
size(displayWidth,displayHeight,P2D); // P2D tells proccessing to use openGL, remove argument if you want to use the basic render-er (about 5x slower)
frameRate(10); // slows down the render for less cpu usage and less flashy display
}
 
// Every frame
void draw() {
// After growing to the whole screen, we tell the hearts to use a different color and start small again
if(scalevalue > 10 ) {
scalevalue = 0.8;
colorcode = -colorcode;
}
// This changes the colors based on which pass the we are in.
if(colorcode < 0 ) {
// fade out background to purple
colorMode(RGB);
fill(128,0,128,10);
rect(0,0,width,height);
// Colors of heart has moved to inside the heart creation loop below
} else {
// fade out background to white
colorMode(RGB);
fill(255,5);
rect(0,0,width,height);
// Wife loves purple!
fill(128,0,128);
stroke(128,0,128);
}
translate((width/2), (height/2));
scale(scalevalue);
// Draw a bunch of hearts
for(int i = 0; i <10; i++){
// Lets add some splat:
// Every pass through the loop, move them by a random ammount
// note: due to the translations coalescing causes wandering drunk phenomena where it splays outward from the origin
translate(0.2*scalevalue*random(-(width/15),width/15), 0.2*scalevalue*random(-(height/15),height/15));
// Lets add some spin
// Rotate the next heart at random
rotate(random(PI));
// Lets add random colors (using HSB to make the math easier)
if(colorcode < 0 ) {
colorMode(HSB);
int thehue = int(random(255));
int thesat = int(random(100,255));
int thebal = int(random(200,255));
fill(thehue,thesat,thebal);
stroke(thehue,thesat,thebal);
}
//A better heart done with bezier curves
beginShape();
vertex(0, -5);
bezierVertex(0, -30, 40, -20, 0, 30);
vertex(0,-5);
bezierVertex(0, -30, -40, -20, 0, 30);
endShape();
/* // my bad triangle based heart
arc(-25,-25,circlewidth,circlewidth,PI,TWO_PI);
arc(25,-25,circlewidth,circlewidth,PI,TWO_PI);
triangle(-50,-25,50,-25,0,70);
*/
}
 
// Grow heart size for next pass
scalevalue *= scalefactor;
println("scalevalue:"+scalevalue); // Because console
 
}
 
void mousePressed() {
stop();
exit();
}
 
void keyPressed() {
stop();
exit();
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.