xxxxxxxxxx
131
/*
Meme Animation
Alina Perdomo
11/25/22
Image taken from Peakpx
https://www.peakpx.com/en/hd-wallpaper-desktop-vqbzp
Image taken from Pinterest
https://www.pinterest.com/pin/719731584185287809/
Image taken from Pinterest
https://www.pinterest.com/pin/139682025932413191/
Image taken from Pinterest
https://www.pinterest.com/pin/61783826108162628/
*/
var cat1;
var cat2;
var cat3;
var textMe = "Me";
var text2 = "taking a shower @ 5am before work";
var text3 = "waking up at 4:50am";
var text4 = "starting my 6am work shift";
var text5 = "when I get my paycheck";
state = 0;
var r = 0; //rotation for animation
var rSpeed = 0.01;
var s = 1; //image scale
var sSpeed = 0.003;
function mousePressed() {
state = state + 1;
if (state > 3) {
state = 0;
}
//save ('ani.png');
}
function preload() {
cat2 = loadImage("catCry.jpg");
cat1 = loadImage("cat1.jpg");
cat3 = loadImage("sleepyC.jpg");
cat4 = loadImage("coolC.jpg");
}
function setup() {
createCanvas(400, 500);
}
function draw() {
var h = height;
var w = width;
imageMode(CENTER);
textAlign(CENTER);
fill("white");
stroke("black");
strokeWeight(3);
textFont("Impact");
//1st state
push();
translate(w / 2, h / 2);
scale(s);
image(cat3, 0, 0, 450, 510);
s += sSpeed;
if (s > 1.5 || s < 1) {
sSpeed *= -1;
}
pop();
textSize(25);
text(text3, w / 2, h - 50);
//second statement
if (state === 1) {
push();
translate(w / 2, h / 2);
scale(s);
image(cat2, 0, 0, 400, 500);
s += sSpeed;
if (s > 2 || s < 1) {
sSpeed *= -1;
}
pop();
text(text2, w / 2, h - 40);
//thrid statement
} else if (state === 2) {
push();
translate (w / 2, h / 2);
scale (s + 0.5);
image(cat1, 0, 0, 480, 500);
s += sSpeed;
if (s > 2 || s < 1) {
sSpeed *= -1;
}
pop ();
text(text4, w / 2, h - 40);
//last statement
} else if (state === 3) {
push ();
translate (w /2, h / 2);
scale (s);
image(cat4, 0, 0, 400, 500);
s += sSpeed;
if (s > 2 || s < 0.5 ) {
sSpeed *= -1; }
pop();
text(text5, w / 2, h - 40);
}
textSize(40);
text(textMe, w / 2, 50);
}