This seems like a silly one, but I'm struggling to get my head around it.
I'm trying to
get the colour of pixels near to a boid, which I'll then use to determine its direction. However, it seems that the
get() function doesn't
translate()...in the following code, the returned value is always the original canvas's 0,0, not the
translated 0,0.
This is happening within a boid class.
My code is (within a boid class which has the location loc.x, loc.y, and rotated to theta):
pushMatrix();
translate(loc.x, loc.y);
rotate(theta);
color current = bgd.get(0, 0); // <---- here's the problem
int redValue = int(red(current));
int greenValue = int(green(current));
int blueValue = int(blue(current));
//do whatever with the values
popMatrix();
I'm not sure how to work out how to get the value from this location, and the surrounding pixels. Any help? I've been working on this all day, and just can't work it out! Probably a real newbie question, apologies!