Move cursor to play with rain rate and direction. Press mouse to see white raindrops.
xxxxxxxxxx
//// Francisco Cuevas Coria
//// Final Project
//// Beer Can Lable Creator for a new beer release called, Laser Rain.
//// Rain direction changes based on mouse position.
//// Rain rate increases as the mouse position move higher or lower on the screen.
//// Press mouse to change color rain to pure white drops.
//// Press any key to save a PDF of the frame.
//// PDF can be found in sketch folder.
int x = 0;
int y = 0;
float amount;
float angle;
// PImage info;
PImage name;
import processing.pdf.*;
boolean record;
void setup () {
size(576, 360);
// info = loadImage("beerINFO.png"); // Beer info including breweries and government info.
name = loadImage("laserrainname.png"); // Beer name, used a font from Adobe Typekit so I created a PNG file.
smooth();
}
void draw() {
// if (record) {
// beginRecord(PDF, "frame-####.pdf");
// }
background(28, 24, 24);
// image(info, 0, 0);
// Rain drop rate
amount = map(mouseY, 0, height, 10, 100);
for (int i = 0; i < amount; i++){
// float xpos = random (0+86, width);
float xpos = random (0, width);
float ypos = random (0, height);
rainDrops(xpos, ypos);
}
image(name, 150, 200);
// if (record) {
// endRecord();
// record = false;
// }
}
void keyPressed() {
record = true;
}
// Rain drops
void rainDrops(float xpos, float ypos) {
pushMatrix();
translate (xpos, ypos);
angle = map(mouseX, 0, width, 0.8, -0.8); // Direction of rain drops
rotate(angle);
strokeWeight(2);
if (mousePressed) { //Converts color drops to pure White
stroke(255);
line(0, 0, 0, random(20, 40));
} else {
// blendMode(ADD);
int selected = (int)random(0, 4);
int choicesR[] = {241, 242, 71, 29};
int choicesG[] = {217, 41, 74, 255};
int choicesB[] = {26, 189, 143, 189};
color r1 = color(choicesR[selected], choicesG[selected], choicesB[selected]);
stroke(r1);
line(0, 0, 0, random(20, 40));
}
popMatrix();
}