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);
精彩评论