I' using KineticJS to drawing a logo, both top an bottom lines are bezierCurveTo.
I need to draw lines between them and so I need to locate the points inside both curves.
What I thought to use was get the X coordinate and get the Y coordinate. Using method bezierCurveTo I can find the position. The problem is bezierCurveTo use the first parameter as percent and my two berzier are not equivalent, so is not a solution for me.
Is there any function that given tree points and X returns the Y ?
Edited
I'll try to explain it better with the next example I have the point C. I need the point A and B which are the intersection of the vertical line given by the point C and the bezier curves, but beziers are not functions.
Given an X coordinate: How to get the Y coordinate of 2 vertically stacked bezier curves.
I can think of 2 ways, both use “brute force”.
First method: examine pixels:
Here is code and Fiddle for the first method: http://jsfiddle.net/m1erickson/uRDYf/
Second method: use the Bezier curve formula to repeatedly "guess" the Y coordinate.
FYI, the cubic Bezier actually does have a formula
And you can calculate XY points along that formula like this:
So the second method is to repeatedly "guess" T values along your curve using getCubicBezierXYatT.
When the returned X is your desired X, you also have your desired Y.
I haven't tried it, but this SO post uses something called the Newton-Raphson refinement to make better than random guesses:
Getting y from x co-ord for cubic bezier curve, fast Newton-Raphson method