/*Kimberlyn Cho
ycho2@andrew.cmu.edu
Section C
Project 09 */
var underlyingImage;
//array of emoticons to choose from
var words = [";)", ":P", ">_<", "^.^", "<3"];
var expression = ["damnnn", "wow", "omg", "beautiful"]
function preload() {
var myImageURL = "https://i.imgur.com/mZFEEAK.jpg";
underlyingImage = loadImage(myImageURL);
};
function setup() {
createCanvas(360, 480);
background(0);
underlyingImage.loadPixels();
frameRate(10);
};
function draw() {
var px = random(width);
var py = random(height);
var ix = constrain(floor(px), 0, width-1);
var iy = constrain(floor(py), 0, height-1);
var theColorAtLocationXY = underlyingImage.get(ix, iy);
noStroke();
fill(theColorAtLocationXY);
//randomize emoticon choice
var textchoice = floor(random(0, 5));
//randomize emoticon size
var sizechoice = floor(random(10, 20));
textSize(sizechoice);
//choosing from array of emoticons
text(words[textchoice], px, py);
};
function mousePressed() {
//generating "damnnn" with mousePressed
var theColorAtTheMouse = underlyingImage.get(mouseX, mouseY);
fill(theColorAtTheMouse);
var textchoice = floor(random(0, 4));
var sizechoice = floor(random(10, 20));
textSize(sizechoice);
text(expression[textchoice], mouseX, mouseY);
};
I chose my best friend from home for this assignment because I miss her very much. I used cute emoticons to represent her lovable and adorable character. I randomized the size and emoticon choice to vary the process. Lastly, I generated my first reactions to seeing this photo with the mouse pressed function.