简体   繁体   English

对贝塞尔曲线绘制的曲线实施接触方法

[英]Implement touches methods to the curve drawn by bezier curve

如何在iPad中实现贝塞尔曲线绘制的曲线上的触摸。

You can use the containsPoint: method of UIBezierPath to work out if a touch is within a curve. 如果触摸在曲线内,则可以使用UIBezierPath的containsPoint:方法来计算。 However this only works if the path is of a closed type eg a circle or rectangle. 但是,这仅在路径为闭合类型(例如圆形或矩形)时才有效。

One thing i have never tested is if a path is implicitly closed by an invisible line from start point to end point. 我从未测试过的一件事是,从起点到终点,一条路径是否被一条不可见的线隐式闭合。 As in 3 sides of a polygon can detect a hit within the 4 sides when the 4th side doesn't exist except in your imagination. 就像多边形的3面一样,当第4面不存在时(在您的想象中),可以检测到4面内的碰撞。

For the case where the curve is a single stroke (as in a painting program) you will have to artificially expand the stroke to detect your touch. 对于曲线是单个笔触的情况(如在绘画程序中),您将不得不人为地扩展笔触以检测触摸。 One way to achieve this is run tangents from each end and draw a parallel line of the same shape along the curve most vector programs do when you request "expand line/stroke" then you can detect a hit within that expanded stroke. 实现此目的的一种方法是从两端开始切线,并沿着大多数矢量程序在请求“扩展线/笔划”时沿曲线绘制相同形状的平行线,然后可以检测到该扩展笔划内的命中。 The fatness of your expanded stroke will determine how accurate the touch has to be. 中风的肥胖程度将决定触摸的精确度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM