xxxxxxxxxx
56
let strokeVal;
let r, g, b;
let imgSize;
// preload 3 "stamps"
function preload() {
doraemon = loadImage("imgs/doraemon.png");
dog = loadImage("imgs/dog.png");
spongebob = loadImage("imgs/spongebob.png");
}
function setup() {
createCanvas(400, 400);
background(random(230,250), random(100, 220), random(100, 220));
imgSize = random(0,50);
}
function draw() {
// draw, clear and change pen icons with keyboard
if (keyIsPressed){
if (key=="R" || key=="r"){ // reset canvas to random color
background(random(230,250), random(100, 220), random(100, 220));
}
if (key=="1"){
imgSize = random(50,70);
image(spongebob, mouseX, mouseY, imgSize, imgSize);
console.log();
}
if (key=="2"){
imgSize = random(40,80);
image(dog, mouseX, mouseY, imgSize+20, imgSize-10);
console.log();
}
if (key=="3"){
imgSize = random(40,70);
image(doraemon, mouseX, mouseY, imgSize, imgSize);
console.log();
}
if(key == "4" || key == "4"){
strokeVal = random(10,40);
r = mouseX;
g = mouseY;
b = random(255);
stroke(r,g,b);
strokeWeight(strokeVal);
line(pmouseX,pmouseY,mouseX,mouseY);
}
}
}