2014/04/07

Connect dots by quadratic Bezier curve

I wanted to connect dots smoothly, like note apps.
The dots are got by UIResponder’s :

touchesBegan:withEvent:
touchesMoved:withEvent:

I can got touched points. If the points are connected by line, the line does not look smoothly.
So I tried to make it smooth by using Bezier curve.
This is the result which were drawn by my original idea :

curve by my original algorithm

↑ It got worse! orz
The red left line is made by just connecting with line. Blue points on the red line are got by UIResponder.
The green right line is shifted by some pixels, small green points are control point of Bezier curve.
I just calculate a new control point by current point and previous control point. Anyway this way is not good.

Suddenly I remembered a post about this, and looked my Evernote and found next post :

Capture a Signature on iOS

At first I was not able to understand what this code meant. But the result is here :

fixed by quadratic Bezier curve

↑Wow! GREAT! The rightest line is the one with this new way.
This way uses touch a point as a control point. This is a really nice idea!
Develop | Comments(2) | Trackback(0)
Comment
Comment is pending approval.
Comment is pending blog author's approval.
Comment is pending approval.
Comment is pending blog author's approval.

管理者のみに表示