Created
April 12, 2022 12:33
-
-
Save steveruizok/ec13a67a61af0c31a9733e25c8b770dc to your computer and use it in GitHub Desktop.
Find the control points for a quadratic bezier curve segment from point a to point c passing through point b.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Find the control points for a quadratic segment from point a to point c passing through point b. | |
* @param a The segments's first point | |
* @param b The point to curve through | |
* @param c The segment's end point | |
*/ | |
export function getQuadraticControlPoints( | |
a: { x: number; y: number }, | |
b: { x: number; y: number }, | |
c: { x: number; y: number } | |
) { | |
return { | |
a, | |
c1: { | |
x: b.x + (b.x - (a.x + c.x) * 0.5), | |
y: b.y + (b.y - (a.y + c.y) * 0.5) | |
}, | |
c | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Demo at https://codesandbox.io/s/find-handle-for-quadradic-curve-c20q5f