boolean openPath = false;
switch(_mode) {
case PConstants.POINTS:
for(int i=0; i<numv; ++i) {
HVertex curr = vertex(i);
if(curr.u()==relX/_width && curr.v()==relY/_height) return true;
}
return false;
case PConstants.PATH:
openPath = true;
if(HColors.isTransparent(_fill)) {
HVertex prev = vertex(openPath? 0 : numv-1);
for(int i=(openPath? 1 : 0); i<numv; ++i) {
HVertex curr = vertex(i);
if(curr.inLine(prev,relX,relY)) return true;
prev = curr;
if(openPath) openPath = false;
}
return false;
}
default:
float u = relX / _width; // TODO remove these, use relX,relY
float v = relY / _height; //
boolean isIn = false;
HVertex prev = vertex(numv-1);
HVertex pprev = vertex(numv>1? numv-2 : 0);
for(int i=0; i<numv; ++i) {
HVertex curr = vertex(i);
if(curr.intersectTest(pprev,prev, u,v, openPath)) isIn = !isIn;
pprev = prev;
prev = curr;
if(openPath) openPath = false;
}
return isIn;