the relation of the bezier Curve and ellipse?

前端 未结 5 2199
南笙
南笙 2020-12-18 05:03

I want to draw a oval in html5 canvas,and i found a good method for it in stackoverflow.but I have another quesition.

function drawEllipse(ctx, x, y, w, h) {         


        
5条回答
  •  天命终不由人
    2020-12-18 05:47

    It can be mathematically proven, that circle can not be made with Bézier curve of any degree. You can make "almost circle" by approximating it.

    Say you want to draw a quarter of circle around [0,0]. Cubic bézier coordinates are:

    [0   , 1   ]
    [0.55, 1   ]
    [1   , 0.55]
    [1   , 0   ]
    

    It is a very good approximation. Transform it linearly to get an ellpise.

提交回复
热议问题