美文网首页
canvas画椭圆

canvas画椭圆

作者: CRJ997 | 来源:发表于2021-10-21 13:55 被阅读0次

摘自文章Canvas画椭圆的方法

function EllipseTwo(context, x, y, a, b) {
    context.save();
    var r = (a > b) ? a : b;
    var ratioX = a / r;
    var ratioY = b / r;
    context.scale(ratioX, ratioY);
    context.beginPath();
    context.arc(x / ratioX, y / ratioY, r, 0, 2 * Math.PI, false);
    context.closePath();
    context.restore();
    context.fill();
}

相关文章

网友评论

      本文标题:canvas画椭圆

      本文链接:https://www.haomeiwen.com/subject/ckmfaltx.html