xxxxxxxxxx
73
/*
----- Coding Tutorial by Patt Vira -----
Name: Falling Letters w Secret Message
Video Tutorial: https://youtu.be/KdVgpDjmoRQ
Connect with Patt: @pattvira
https://www.pattvira.com/
----------------------------------------
*/
let num = 5; let size = 20;
let rain = []; let cols; let dy; let bg;
let ellipseSize = 50; let heartSize = 3;
let alphabets = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"];
let secretMsg = "i love you";
let font;
function preload() {
font = loadFont("fonts/Outfit-Black.ttf");
}
function setup() {
createCanvas(400, 400);
cols = width/size;
for (let i=0; i<cols; i++) {
let x = i*size + size/2;
rain[i] = new Rain(x);
}
bg = color(255);
dy = random(2, 4);
}
function draw() {
background(bg);
if (mouseIsPressed) {
// ellipseSize = 100;
heartSize = 6;
bg = color(0);
dy = random(1);
fill(225,107,153);
} else {
// ellipseSize = 50;
heartSize = 3;
bg = color(100,161,108);
dy = random(2, 4);
fill(233, 176, 200);
}
stroke(0);
strokeWeight(5);
// ellipse(mouseX, mouseY, ellipseSize, ellipseSize);
push();
translate(mouseX, mouseY);
beginShape();
for (let i=0; i<TWO_PI; i+=0.05) {
let x = heartSize * 16*sin(i)*sin(i)*sin(i);
let y = heartSize * -1*(13 * cos(i) - 5*cos(2*i) - 2*cos(3*i) - cos(4*i));
vertex(x, y);
}
endShape();
pop();
for (let i=0; i<cols; i++) {
rain[i].update(dy);
rain[i].restart();
rain[i].display();
}
}