Hello there,

i'm wondering if there is a way to get the pixel-information of a shape. (dont know if thats the right term)

I'm having loads of shapes (.svg) placed on my canvas, and now i want to activate them by clicking on

them with the mouse.

I would have compared my mouseX and mouseY with the pixels of my shapes to know which one should

be activated.

Maybe there is a shorter / easier way?

Or do you know how i get the information what pixels on my shape is lying?

Thanks!

Here's bit of my code:

void getShape() {

clickX = int(mouseX);

clickY = int(mouseY);

//check if there is a shape (shape is filled with black)

if (get(clickX, clickY) == color(0) ) {

for (int i = 0; i < numXmax; i++) {

for (int j = 0; j < numYmax; j++) {

//points[i][j] contains informations to where to place my shape

PVector point = new PVector(points[i][j].pX, points[i][j].pY);

PVector mouse = new PVector(clickX, clickY);

points[i][j].dist = PVector.dist(point, mouse);

if (points[i][j].dist <= 15) {

points[i][j].hit = true;

println("hit"); // just to check if i hit my shape

}

}

}

}

}

i'm wondering if there is a way to get the pixel-information of a shape. (dont know if thats the right term)

I'm having loads of shapes (.svg) placed on my canvas, and now i want to activate them by clicking on

them with the mouse.

I would have compared my mouseX and mouseY with the pixels of my shapes to know which one should

be activated.

Maybe there is a shorter / easier way?

Or do you know how i get the information what pixels on my shape is lying?

Thanks!

Here's bit of my code:

void getShape() {

clickX = int(mouseX);

clickY = int(mouseY);

//check if there is a shape (shape is filled with black)

if (get(clickX, clickY) == color(0) ) {

for (int i = 0; i < numXmax; i++) {

for (int j = 0; j < numYmax; j++) {

//points[i][j] contains informations to where to place my shape

PVector point = new PVector(points[i][j].pX, points[i][j].pY);

PVector mouse = new PVector(clickX, clickY);

points[i][j].dist = PVector.dist(point, mouse);

if (points[i][j].dist <= 15) {

points[i][j].hit = true;

println("hit"); // just to check if i hit my shape

}

}

}

}

}

1