xxxxxxxxxx
let color1, color2, color3;
let btn1x = 100;
let btn2x = 200;
let btn3x = 300;
let btnW = 80;
let btnY = 100;
function setup() {
createCanvas(windowWidth, windowHeight);
background(200);
color1 = color(255, 255, 0);
color2 = color(255, 0, 255);
color3 = color(0, 255, 255);
}
function draw() {
//noStroke();
strokeWeight(0);
fill(color1);
ellipse(btn1x, btnY, btnW, btnW);
fill(color2);
ellipse(btn2x, btnY, btnW, btnW);
fill(color3);
ellipse(btn3x, btnY, btnW, btnW);
}
function mouseDragged() {
strokeWeight(3);
line(mouseX, mouseY, pmouseX, pmouseY);
}
function mousePressed() {
let d1 = dist(mouseX, mouseY, btn1x, btnY);
if (d1 < btnW / 2) {
stroke(color1);
}
let d2 = dist(mouseX, mouseY, btn2x, btnY);
if (d2 < btnW / 2) {
stroke(color2);
}
let d3 = dist(mouseX, mouseY, btn3x, btnY);
if (d3 < btnW / 2) {
stroke(color3);
}
}
function keyTyped() {
if (key == ' ') {
clear();
background(200);
}
}