fixed a bug in the svg rect importer

This commit is contained in:
hneemann 2018-11-30 20:59:04 +01:00
parent 15f35228a9
commit caf8f6c2d3

View File

@ -152,6 +152,8 @@ public class SvgImporter {
VectorInterface pos = vec(element.getAttribute("x"), element.getAttribute("y")); VectorInterface pos = vec(element.getAttribute("x"), element.getAttribute("y"));
VectorInterface rad = vec(element.getAttribute("rx"), element.getAttribute("ry")); VectorInterface rad = vec(element.getAttribute("rx"), element.getAttribute("ry"));
final Polygon polygon;
float x = pos.getXFloat(); float x = pos.getXFloat();
float y = pos.getYFloat(); float y = pos.getYFloat();
float width = size.getXFloat(); float width = size.getXFloat();
@ -166,7 +168,7 @@ public class SvgImporter {
float cx = (float) (f * rx); float cx = (float) (f * rx);
float cy = (float) (f * ry); float cy = (float) (f * ry);
csd.addPolygon(new Polygon(true) polygon = new Polygon(true)
.add(c.v(x + rx + w, y)) .add(c.v(x + rx + w, y))
.add(c.v(x + rx + w + cx, y), c.v(x + width, y + ry - cy), c.v(x + width, y + ry)) .add(c.v(x + rx + w + cx, y), c.v(x + width, y + ry - cy), c.v(x + width, y + ry))
.add(c.v(x + width, y + ry + h)) .add(c.v(x + width, y + ry + h))
@ -174,13 +176,18 @@ public class SvgImporter {
.add(c.v(x + rx, y + height)) .add(c.v(x + rx, y + height))
.add(c.v(x + rx - cx, y + height), c.v(x, y + ry + h + cy), c.v(x, y + ry + h)) .add(c.v(x + rx - cx, y + height), c.v(x, y + ry + h + cy), c.v(x, y + ry + h))
.add(c.v(x, y + ry)) .add(c.v(x, y + ry))
.add(c.v(x, y + ry - cy), c.v(x + rx - cx, y), c.v(x + rx, y)), c.getThickness(), c.getColor(), false); .add(c.v(x, y + ry - cy), c.v(x + rx - cx, y), c.v(x + rx, y));
} else } else
csd.addPolygon(new Polygon(true) polygon = new Polygon(true)
.add(c.v(x, y)) .add(c.v(x, y))
.add(c.v(x + width, y)) .add(c.v(x + width, y))
.add(c.v(x + width, y + height)) .add(c.v(x + width, y + height))
.add(c.v(x, y + height)), c.getThickness(), c.getColor(), false); .add(c.v(x, y + height));
if (c.getFilled() != null)
csd.addPolygon(polygon, c.getThickness(), c.getFilled(), true);
if (c.getColor() != null)
csd.addPolygon(polygon, c.getThickness(), c.getColor(), false);
} }
private void drawCircle(CustomShapeDescription csd, Element element, Context c) { private void drawCircle(CustomShapeDescription csd, Element element, Context c) {