JavaFX – SVGPath


We recently celebrated Holi – Festival of Colours.
It was real fun! Now lets try to celebrate Holi with JavaFX!.

You can create an SVG path in JavaFX using SVGPath class. It accepts content which is a string formatted as specified here.


SVGPath {
    content: "M48.859,43.518c8.424,17.64,2.736,140.832-7.128,184.032"
             "c-9.864,43.272-19.728,98.28-22.032,144.576c-1.008,19.728,"
             "2.016,27.504,14.904,27.504c22.752,0,51.624-47.952,87.84-46.872"
             "c36.288,1.08,47.808,55.008,64.8,54.648c16.992-0.36,30.672-6.264,"
             "30.816-58.752C218.563,191.981,87.235,64.973,48.859,43.518"
             "L48.859,43.518L48.859,43.518L48.859,43.518z"
    fill: Color.BLACK
}

We can combine a series of SVGPath to create the final image. Now we can manipulate attributes of individual SVGPath such as fill, stroke, strokeWidth etc. I’m using the same ColorChooser code as in previous post.

For Applet mode, click on above image

For standalone mode

To paint Duke select any part of Duke and then select a color from color chooser.
Now you can play Holi with Duke! Have fun!

Source

var dzone_url = “http://blogs.sun.com/rakeshmenonp/entry/javafx_svgpath”;
var dzone_style = ‘2’;