p5 js if mouse pressed
if (mouseIsPressed)
p5 js if mouse pressed
let cnv;
let d;
let g;
function setup() {
cnv = createCanvas(100, 100);
cnv.mousePressed(changeGray); // attach listener for
// canvas click only
d = 10;
g = 100;
}
function draw() {
background(g);
ellipse(width / 2, height / 2, d, d);
}
// this function fires with any click anywhere
function mousePressed() {
d = d + 10;
}
// this function fires only when cnv is clicked
function changeGray() {
g = random(0, 255);
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us