Skip to content

Instantly share code, notes, and snippets.

@LukeMcNemee
Last active December 5, 2016 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LukeMcNemee/8d53f770b778720266b0 to your computer and use it in GitHub Desktop.
Save LukeMcNemee/8d53f770b778720266b0 to your computer and use it in GitHub Desktop.
svg snippets for Java
//svg header
public void toSvg(BufferedWriter bw) throws IOException {
bw.append("<svg xmlns=\"http://www.w3.org/2000/svg\">\n");
for (GraphicsObject g : graphics) {
g.toSvg(bw);
}
bw.append("</svg>\n");
}
//svg for circle
public void toSvg(BufferedWriter bw) throws IOException {
bw.append("<circle cx=\""+ cx +"\" cy=\""+cy+"\" r=\""+r+"\" stroke=\"" +stroke+ "\" stroke-width=\""+ strokeWidth+"\" fill=\""+ fill+"\"/>\n");
}
//svg for rectangle
public void toSvg(BufferedWriter bw) throws IOException {
bw.append("<rect x=\""+ x +"\" y=\""+y+"\" height=\""+height+"\" width=\""+width+"\" stroke=\"" +stroke+ "\" stroke-width=\""+ strokeWidth+"\" fill=\""+ fill+"\"/>\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment