Duc
Duc

Reputation: 501

convert points to svg path/file in java

I wrote a simple drawing application using vaadin, from my app I collect all the points coordinate which are generated by using moving mouse on a canvas. What is the best way to convert these points data into svg? Many thanks

Upvotes: 0

Views: 1412

Answers (1)

Peter Collingridge
Peter Collingridge

Reputation: 10969

If you want a line that follows the points, then create a path element line this:

<path d="Mx0 y0 Lx1 y1 x2 y2 x3 y3 ... Z"/>

Where x0, y0 etc. are the coordinates you have. The Z is optional; it creates a closed polygon by adding a straight line from the last point to the first, and lets you apply a fill style instead of just a line style.

Upvotes: 1

Related Questions