// inspire de Jonas Raoni Soares Silva// http://jsfromhell.com/math/is-point-in-poly [rev. #0]boolean isPointIn(PVector pt){
boolean c = false;
for(int i = -1, l = pts.size(), j = l - 1; ++i < l; j = i)
if (((pts.get(i).y <= pt.y && pt.y < pts.get(j).y) || (pts.get(j).y <= pt.y && pt.y < pts.get(i).y))
&& (pt.x < (pts.get(j).x - pts.get(i).x) * (pt.y - pts.get(i).y) / (pts.get(j).y - pts.get(i).y) + pts.get(i).x))
c = !c;
return c;
}
le code de la fonction colorDist()
/** CALCULATES A 'DISTANCE' BETWEEN TWO COLORS dist=0.0 should mean the very same color. distance between black and white should be 1 distance between opaque and transparent color should be 1 from: http://stackoverflow.com/questions/5066439/compare-pixel-colour-java with alpha and normalisation added ***/float colorDist(color c1, color c2) {
float rmean =(red(c1) + red(c2)) / 2;
float r = red(c1) - red(c2);
float g = green(c1) - green(c2);
float b = blue(c1) - blue(c2);
float a = (alpha(c1) - alpha(c2))/255.0;
return Math.max(a, sqrt((int(((512+rmean)*r*r))>>8)+(4*g*g)+(int(((767-rmean)*b*b))>>8))/764.8333);
} // colorDist()