Page 1 of 1

vector quadratic curve

Posted: Fri Apr 22, 2022 7:33 am
by Rinzwind
https://developer.apple.com/documentati ... rvetopoint
- (void)addQuadCurveToPoint:(CGPoint)endPoint
controlPoint:(CGPoint)controlPoint;

https://developer.apple.com/documentati ... rvetopoint
- (void)addCurveToPoint:(CGPoint)endPoint
controlPoint1:(CGPoint)controlPoint1
controlPoint2:(CGPoint)controlPoint2;

Is it me, or is a 'quadratic Bézier curve' missing in the PB vector library?

Re: vector quadratic curve

Posted: Fri Apr 22, 2022 4:37 pm
by Michael Vogel
Convert it to 'standard' bezier curves which are available in the vector library.

Re: vector quadratic curve

Posted: Sat Apr 23, 2022 4:59 am
by Rinzwind
Distilled and converted from your link and for future reference/help:

Code: Select all

Procedure AddPathCurveQuad(cpx.d, cpy.d, x.d, y.d, Flags = #PB_Path_Default)
  Define cx.d, cy.d
  If Flags = #PB_Path_Default
    cx = PathCursorX()
    cy = PathCursorY()
  EndIf
  
  AddPathCurve(cx + (2.0 / 3.0) * (cpx - cx), 
               cy + (2.0 / 3.0) * (cpy - cy),
               x + (2.0 / 3.0) * (cpx - x),
               y + (2.0 / 3.0) * (cpy - y),
               x, y, Flags)
EndProcedure
Seems to do the trick. Still weird it's not there out-of-the-box.

<edit some bad typo's>