简体   繁体   中英

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. 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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