mstahv / vaadin-flow-canvas

Canvas component for Vaadin 10+

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Canvas Component for Vaadin 10+

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.

Usage Example

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.

Development Instructions

Starting the test/demo server:

mvn jetty:run

This deploys the demo at http://localhost:8080

About

Canvas component for Vaadin 10+

License:Other


Languages

Language:Java 100.0%