Reputation: 263
i have three points in 2D and I want to draw a spline curve passing through them. How do I calculate the middle point (x1 and y1 as in quadTo)? i want to implement free curve like denon eq curve
Upvotes: 1
Views: 352
Reputation: 437442
For the first segment of the curve, you can probably use addQuadCurveToPoint
, picking a control point with the same y
value as the second point (and I picked an x
value half way between the two end points):
For the second portion of the curve, you can't use quad curve, because you need two control points (or, you'd have to break it up into two quad curves, which is more hassle than its worth, IMHO). So use addCurveToPoint
, using control point y
values that are the same value as the y
value of the point to which the control point refers (and, again, I picked x
values half way between the x
values of the two end points):
There are lots of permutations of this idea, but I hope this illustrates the concept. I'd suggest you start playing around with UIBezierPath
and addCurveToPoint
until you achieve the desired effect.
Upvotes: 2