xxxxxxxxxx
27
let fruits;
function preload()
{
fruits = loadImage ("fruits.png");
}
function setup() {
createCanvas(500, 500);
}
function draw() {
background(220);
image(fruits, 0, 0);
//Get the color at the mouse position
let c = fruits.get(mouseX, mouseY);
// Change the fill to that color
fill(c);
// Draw a square with that color
noStroke()
square(mouseX, mouseY, 50);
}