Get() and images

Hi all,

With the following sketch, the image is drawn at (140, 500). However, when I sample the image using the get() function, it acts as though the image is drawn at (0, 0). How do I correct this?

Thanks!

let colours;

function setup() {
	colours = loadImage('colours.jpg');
	createCanvas(700, 700);
	background(0);
}

function draw() {
	image(colours, 140, 500, 190, 110);

	fill(colours.get(mouseX, mouseY));
	noStroke();
	ellipse(50, 50, 50, 50);
}
1 Like

with

colours.get();

read from the image,
with

get();

from the canvas,
difference is, that is where you actually placed the image.

3 Likes

Amazing! Thank you so much :slight_smile:

1 Like