xxxxxxxxxx
function setup() {
createCanvas(windowWidth, windowHeight);
background(255);
}
function draw() {
noStroke();
push();
fill(0,0,0)
rect(0,0,50,50);
fill(0,255,0)
rect(0,50,50,50);
fill(0,0,255)
rect(0,100,50,50);
fill(255,0,0)
rect(0,150,50,50)
fill(255,255,0)
rect(0,200,50,50)
fill(255,165,0)
rect(0,250,50,50)
fill(255,0,255)
rect(0,300,50,50)
fill(139,69,19)
rect(0,350,50,50)
pop();
if (mouseIsPressed){
if (dist(mouseX,mouseY,50,50) < (50))
{
fill(0,0,0)
}
if (dist(mouseX,mouseY,50,100) < (50))
{
fill(0,255,0)
}
if (dist(mouseX,mouseY,50,150) < (50))
{
fill(0,0,255)
}
if (dist(mouseX,mouseY,50,200) < (50))
{
fill(255,0,0)
}
if (dist(mouseX,mouseY,50,250) < (50))
{
fill(255,255,0)
}
if (dist(mouseX,mouseY,50,300) < (50))
{
fill(255,165,0)
}
if (dist(mouseX,mouseY,50,350) < (50))
{
fill(255,0,255)
}
if (dist(mouseX,mouseY,50,400) < (50))
{
fill(139,69,19)
}
}
//print(mouseX + "," + mouseY)
if (mouseIsPressed){
ellipse(mouseX, mouseY, 20, 20);
}
}