如何为 CCMenuItem 实现 PNPOLY 来定义非矩形多边形的可触摸区域?
我正在实现可触摸的彩虹,但上带的凹“透明”区域会干扰下彩虹带。我希望使用 (http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html) 中的 PNPOLY,但我不明白它应该如何工作。我希望定义乐队的可触摸区域和透明(不可触摸)区域。
代码:
int pnpoly(int nvert, float *vertx, float *verty, float testx, float testy) {
int i, j, c = 0;
for (i = 0, j = nvert-1; i < nvert; j = i++) {
if (((verty[i]>testy)!= (verty[j]>testy)) &&
(testx < (vertx[j]-vertx[i]) * (testy-verty[i]) / (verty[j]-verty[i]) + vertx[i]) )
<前><代码> c = !c;}
返回c;
}
文献说凹实体的布尔表达式是 ABC(D+E+F)。这如何适合该功能?
I'm implementing a touchable rainbow but the concave 'transparent' areas of a upper band is interfering with the lower rainbow bands. I'm hoping to use PNPOLY from (http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html) but I don't understand how it is supposed to work. I'm hoping to define the band's touchable area and transparent (non-touchable) area.
Code:
int pnpoly(int nvert, float *vertx, float *verty, float testx, float testy)
{int i, j, c = 0;
for (i = 0, j = nvert-1; i < nvert; j = i++) {
if ( ((verty[i]>testy) != (verty[j]>testy)) &&
(testx < (vertx[j]-vertx[i]) * (testy-verty[i]) / (verty[j]-verty[i]) + vertx[i]) )
c = !c;
}
return c;
}
The reference says the boolean expression for a concave entity is A.B.C.(D+E+F). How does this fit into the function?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论