public MarkerSvg(int id, PMatrix2D matrix, PVector size) { this.id = id; this.size = size.get(); this.matrix = matrix.get(); }
public RadialGradient(PShapeSVG parent, XML properties) { super(parent, properties); this.cx = getFloatWithUnit(properties, "cx", svgWidth); this.cy = getFloatWithUnit(properties, "cy", svgHeight); this.r = getFloatWithUnit(properties, "r", svgSizeXY); String transformStr = properties.getString("gradientTransform"); if (transformStr != null) { float t[] = parseTransform(transformStr).get(null); this.transform = new AffineTransform(t[0], t[3], t[1], t[4], t[2], t[5]); Point2D t1 = transform.transform(new Point2D.Float(cx, cy), null); Point2D t2 = transform.transform(new Point2D.Float(cx + r, cy), null); this.cx = (float) t1.getX(); this.cy = (float) t1.getY(); this.r = (float) (t2.getX() - t1.getX()); } } }
public LinearGradient(PShapeSVG parent, XML properties) { super(parent, properties); this.x1 = getFloatWithUnit(properties, "x1", svgWidth); this.y1 = getFloatWithUnit(properties, "y1", svgHeight); this.x2 = getFloatWithUnit(properties, "x2", svgWidth); this.y2 = getFloatWithUnit(properties, "y2", svgHeight); String transformStr = properties.getString("gradientTransform"); if (transformStr != null) { float t[] = parseTransform(transformStr).get(null); this.transform = new AffineTransform(t[0], t[3], t[1], t[4], t[2], t[5]); Point2D t1 = transform.transform(new Point2D.Float(x1, y1), null); Point2D t2 = transform.transform(new Point2D.Float(x2, y2), null); this.x1 = (float) t1.getX(); this.y1 = (float) t1.getY(); this.x2 = (float) t2.getX(); this.y2 = (float) t2.getY(); } } }
float t[] = parseTransform(transformStr).get(null);
float t[] = parseTransform(transformStr).get(null);
MarkerSvg marker = new MarkerSvg(id, matrix.get(), size);
transform.scale(2); //be aware that the order of operation matters! transform.translate(-800,-300); //this matrix can be used to convert from screen coordinats to SVG coordinates coordSysSvgInv = transform.get(); //clone the svg to screen transformation matrix