xxxxxxxxxx
35
//https://www.youtube.com/watch?v=POn4cZ0jL-o&t=370s
// declare variables
let x, y, r, g, b; // you can declare multiple variables on the same line if you put a comma
let drawSmile;
function setup() {
createCanvas(400, 400); // you could also do (windowWidth, windowHeight) and it'll change the size of the canvas according to how you stretch it out, useful for fullscreen option
background(255); // if in function setup, keeps it in the back, unchanged, if in function draw, reapplies in every frame
}
function preload() { // loads images to be used later
smile = loadImage("smile.png");
blue1 = loadImage("BLUE1.png");
green2 = loadImage("GREEN2.png");
pink2 = loadImage("PINK2.png");
peace = loadImage("peace.png");
}
function draw() {
// determining variables
r = random(0, 255); // chooses random value between 0-255
g = random(0, 255);
b = random(0, 255);
x = random(0, 400); // you could also plot width or height here if you change the size of the canvas // x = random(width)
y = random(0, 400);
// randomly generated images
image(smile, x - 50, y - 50, 30, 30);
image(green2, x - 20, y - 20, 50, 50);
image(blue1, x, y, 40, 40);
image(pink2, x - 45, y - 35, 45, 45);
image(peace, x - 20, y - 50, 89.4, 62.85);
}