Find the height of a Bezier curve in canvas

I am trying to create a simple rounded vertex of a rectangle. I was able to use the method bezierCurveToto create the cap, but I had to play with the values ​​of the control point y to get the correct height of the curve. If I have a width and I know that the height I want the curve to go through is their formula to find the values ​​of the control point y? I now have a function

c.moveTo(130,55);
c.bezierCurveTo(130,-18,0,-18,0,55);

-18 is what I needed to set for y values ​​in order to approximate the curve through y = 0.

+3
source share
1 answer

, . wikipedia (t = 0,5), y :

1/4 Ymax + 3/4 Ymin

(Ymax - y , Ymin - y ). , , 0,

Ymin = -1/3 Ymax.

, Ymax = 55, Ymin -1/3 * 55 = -18.333.. - 18 .

+4

Source: https://habr.com/ru/post/1779096/


All Articles