From f86e9b769377ea24f3fc0a0b5410acda596b5947 Mon Sep 17 00:00:00 2001 From: "helmut.neemann" Date: Mon, 27 Jun 2016 15:52:50 +0200 Subject: [PATCH] add opacity to svg-export --- .../java/de/neemann/digital/draw/graphics/GraphicSVG.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/neemann/digital/draw/graphics/GraphicSVG.java b/src/main/java/de/neemann/digital/draw/graphics/GraphicSVG.java index ce4b1cda0..95a6c0f40 100644 --- a/src/main/java/de/neemann/digital/draw/graphics/GraphicSVG.java +++ b/src/main/java/de/neemann/digital/draw/graphics/GraphicSVG.java @@ -109,7 +109,7 @@ public class GraphicSVG implements Graphic, Closeable { // if (style.isDashed()) // addStrokeDash(w, style.getDashArray()); if (style.isFilled() && p.isClosed()) - w.write(" stroke=\"" + getColor(style) + "\" stroke-width=\"" + getStrokeWidth(style) + "\" fill=\"" + getColor(style) + "\"/>\n"); + w.write(" stroke=\"" + getColor(style) + "\" stroke-width=\"" + getStrokeWidth(style) + "\" fill=\"" + getColor(style) + "\" fill-opacity=\""+getOpacity(style)+"\"/>\n"); else w.write(" stroke=\"" + getColor(style) + "\" stroke-width=\"" + getStrokeWidth(style) + "\" fill=\"none\"/>\n"); } catch (IOException e) { @@ -203,6 +203,12 @@ public class GraphicSVG implements Graphic, Closeable { return "#" + Integer.toHexString(style.getColor().getRGB()).substring(2); } + private String getOpacity(Style style) { + double op = style.getColor().getAlpha() / 255.0; + return Double.toString(op); + } + + /** * Escapes a given string to XML *