Last active
December 18, 2015 15:19
-
-
Save ochilab/5803537 to your computer and use it in GitHub Desktop.
GWTでHTML5Canvasを利用して図形を描画する際のサンプル。XMLファイルはUIBinderの記述方法です。
gwt.xmlには <inherits name='com.google.gwt.canvas.Canvas'/>が必要です。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Canvas canvas = Canvas.createIfSupported(); | |
initWidget(uiBinder.createAndBindUi(this)); | |
canvas.setWidth("800px"); | |
canvas.setHeight("800px"); | |
canvas.setCoordinateSpaceWidth(800); | |
canvas.setCoordinateSpaceHeight(800); | |
Context2d context = canvas.getContext2d(); | |
context.fillRect(10, 10, 500, 500); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent"> | |
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" | |
xmlns:g="urn:import:com.google.gwt.user.client.ui" | |
xmlns:c="urn:import:com.google.gwt.canvas.client"> | |
<ui:style> | |
</ui:style> | |
<g:HTMLPanel> | |
<c:Canvas ui:field="canvas"/> | |
</g:HTMLPanel> | |
</ui:UiBinder> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment