// Port unchanged except for path of images
//create an array of fonts
var fonts = ["Courier", "Impact","Helvetica","Consolas"];
var chosenCaption;
var fontColor;
var fontSize;
var chosenFont;
var captions = [
"to catch the squirrel, you must become the squirrel",
"I am your father",
"allow me to sing the song of my people",
"wazzaaaaaaap","Oh boy","I said good day!"];
//create variables for each image
var rabbit;
var baby;
var dog;
var images;
var chosenImage;
//use a preload function to load each image
function preload(){
rabbit= loadImage("/uploads/rpdemo/rabbit.jpg")
baby= loadImage("/uploads/rpdemo/baby.jpeg")
dog= loadImage("/uploads/rpdemo/dog.jpeg")
}
function setup() {
createCanvas(400, 300);
images= [rabbit, baby, dog]
//when the program starts pick a random caption
pickRandom();
}
function draw() {
background(200)
image(chosenImage,0,0,width,height)
//set the font, size and fill to the text variables
textFont(chosenFont);
textSize(fontSize);
fill(fontColor);
strokeWeight(3);
stroke(255);
text(chosenCaption, 20, height/2, 300, 200);
}
//When the mouse is clicked, pick a new random caption
function mouseClicked() {
pickRandom();
}
function pickRandom(){
//choose a random image
chosenImage=images[floor(random(images.length))];
//choose a random caption
chosenCaption=captions[floor(random(captions.length))];
//choose a random font from the array
chosenFont= fonts[floor(random(fonts.length))];
//choose a random color
fontColor = color(random(255), random(255), random(255));
//choose a random font between 20-46
fontSize = random(20, 40);
}