This is a Java integration of the HTML5 <canvas>
for Vaadin Platform.
Currently this add-on provides a subset of the client-side JavaScript API to Java users.
Add the dependency to your Vaadin 10+ project's pom.xml
:
<dependency>
<groupId>org.vaadin.pekkam</groupId>
<artifactId>canvas-java</artifactId>
<version>1.0.1</version>
</dependency>
The API is similar to its client-side counterpart:
Canvas canvas = new Canvas(800, 500);
CanvasRenderingContext2D ctx = canvas.getContext();
// Draw a red line from point (10,10) to (100,100):
ctx.setStrokeStyle("red");
ctx.beginPath();
ctx.moveTo(10, 10);
ctx.lineTo(100, 100);
ctx.closePath();
ctx.stroke();
More examples can be found in the demo sources.
Starting the test/demo server:
mvn jetty:run
This deploys the demo at http://localhost:8080