Friday Mar 13, 2009

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.

<script src="http://dl.javafx.com/1.1/dtfx.js"></script> <script src="/rakeshmenonp/resource/SVGPath/SVGPath.js"></script>

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

<script type="text/javascript">var dzone_url = "http://blogs.sun.com/rakeshmenonp/entry/javafx_svgpath";</script> <script type="text/javascript">var dzone_style = '2';</script> <script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script>

About


The views expressed on this blog are my own and do not necessarily reflect that of my organization

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today