开发者

ellipse vs circle

开发者 https://www.devze.com 2023-02-11 07:44 出处:网络
Canvas canvas = Canvas.createIfSupported();开发者_开发技巧 canvas.setWidth(\"200px\"); canvas.setHeight(\"200px\");


        Canvas canvas = Canvas.createIfSupported();开发者_开发技巧

        canvas.setWidth("200px");
        canvas.setHeight("200px");

        RootPanel.get().add(canvas);

        Context2d context = canvas.getContext2d();
        context.setStrokeStyle("black");

        context.arc(50, 50, 20, 0, Math.PI*2);

        context.stroke();

Why I have ellipse instead of circle here?


You'll also have to set the coordinate space, to make it match the aspect ratio of your canvas. So you can add the following lines:

canvas.setCoordinateSpaceWidth(200);
canvas.setCoordinateSpaceHeight(200);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号