Skip to main content

How to use SVG?

1 reply [Last post]
riepi
Offline
Joined: 2008-03-27

I try to use svg to draw some figures. Perhaps someone can tell me how to use javafx.scene.geometry.SVGPath
In my first tries i used the javafx svg translator but it produces the old javafx code and i have to change many attributes. But it works. I hope SVGPath can make it easier to draw.

greeting Riepi

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
riepi
Offline
Joined: 2008-03-27

just found out how SVGPath works. I drew my Objekt in Adobe Illustrator CS2 and when I want so save as svg Illustrator can show you the svg Code. For every Objekt/Path you find a Path Tag. Copy the String with the coordinates to JavaFx's SVGPath:

[code]
package svgpath;

import javafx.application.*;
import javafx.ext.swing.Canvas;
import javafx.scene.geometry.SVGPath;
import javafx.scene.Group;
import javafx.scene.paint.Color;
import javafx.scene.geometry.Circle;
import java.lang.System;
import javafx.scene.geometry.Rectangle;

var c = Circle {
centerX: 60, centerY: 50
radius: 40
fill: Color.YELLOW
stroke: Color.BLACK
visible: true
}

Frame {
title: "SVGPath"
width: 200
height: 200
closeAction: function() {
java.lang.System.exit( 0 );
}
visible: true
stage: Stage{
content: Group{
content:
[
c,
SVGPath{
content:"M9.904,47.16c0,0-1.809-18.447,27.851-9.766c0,0-0.724-5.787,6.872-6.149
c0,0,9.042-14.468,28.575,3.255c0,0,22.178-1.586,28.213,7.234c4.702,6.872-1.809,9.766-1.809,9.766s12.298,6.511,10.128,12.66
s-14.468,8.32-18.809,5.426c0,0-3.617,10.489-28.937,8.319c-19.851-1.702-24.958-10.127-24.958-10.127s-17.723,14.83-22.425-2.894
c0,0-10.852-1.085-11.937-10.49S9.904,47.16,9.904,47.16z"

stroke: Color.BLACK
fill: Color.WHITE
translateX: 43
translateY: 20
},//SVGPath

]
}//Group
}//Stage
}//Frame
[/code]