diff options
| -rwxr-xr-x | share/attributes/genMapDataSVG.pl | 1 | ||||
| -rw-r--r-- | share/attributes/svgprops | 2 | ||||
| -rw-r--r-- | src/attributes-test.h | 3 | ||||
| -rw-r--r-- | src/attributes.cpp | 1 | ||||
| -rw-r--r-- | src/attributes.h | 1 | ||||
| -rw-r--r-- | src/extension/internal/cairo-render-context.cpp | 3 | ||||
| -rw-r--r-- | src/sp-radial-gradient.cpp | 18 | ||||
| -rw-r--r-- | src/sp-radial-gradient.h | 1 |
8 files changed, 27 insertions, 3 deletions
diff --git a/share/attributes/genMapDataSVG.pl b/share/attributes/genMapDataSVG.pl index d64b1c01d..24e760980 100755 --- a/share/attributes/genMapDataSVG.pl +++ b/share/attributes/genMapDataSVG.pl @@ -83,6 +83,7 @@ push @{$attributes{ "id" }->{elements}}, "flowRoot","flowPara","flowSpan","fl push @{$attributes{ "style" }->{elements}}, "flowRoot","flowPara","flowSpan","flowRect","flowRegion","solidColor"; push @{$attributes{ "xml:space" }->{elements}}, "flowRoot","flowPara","flowSpan"; push @{$attributes{ "transform" }->{elements}}, "flowRoot","flowPara","flowSpan"; +push @{$attributes{ "fr" }->{elements}}, "radialGradient"; # Mesh gradients push @{$attributes{ "id" }->{elements}}, "mesh","meshrow","meshpatch"; diff --git a/share/attributes/svgprops b/share/attributes/svgprops index a34b79202..5df86d68b 100644 --- a/share/attributes/svgprops +++ b/share/attributes/svgprops @@ -90,6 +90,8 @@ "format" - "altGlyph","glyphRef" +"fr" - "radialGradient" + "from" - "animate","animateColor","animateMotion","animateTransform" "fx" - "radialGradient" diff --git a/src/attributes-test.h b/src/attributes-test.h index 1fc3972c0..b8d5d98a5 100644 --- a/src/attributes-test.h +++ b/src/attributes-test.h @@ -42,7 +42,7 @@ public: SVG 2: white-space, shape-inside, shape-outside, shape-padding, shape-margin SVG 2: text-decoration-fill, text-decoration-stroke SVG 2: solid-color, solid-opacity - SVG 2: Hatches and Meshes + SVG 2: Hatches and Meshes, radial gradient 'fr' CSS 3: text-orientation CSS 3: font-variant-xxx, font-feature-settings */ @@ -145,6 +145,7 @@ struct {char const *attr; bool supported;} const all_attrs[] = { {"from", true}, {"fx", true}, {"fy", true}, + {"fr", true}, {"g1", true}, {"g2", true}, {"glyph-name", true}, diff --git a/src/attributes.cpp b/src/attributes.cpp index e32f4ece4..646c2ab0c 100644 --- a/src/attributes.cpp +++ b/src/attributes.cpp @@ -294,6 +294,7 @@ static SPStyleProp const props[] = { /* SPRadialGradient */ {SP_ATTR_FX, "fx"}, {SP_ATTR_FY, "fy"}, + {SP_ATTR_FR, "fr"}, /* SPMeshPatch */ {SP_ATTR_TENSOR, "tensor"}, //{SP_ATTR_TYPE, "type"}, diff --git a/src/attributes.h b/src/attributes.h index 754cc876a..f5544d0a1 100644 --- a/src/attributes.h +++ b/src/attributes.h @@ -296,6 +296,7 @@ enum SPAttributeEnum { /* SPRadialGradient */ SP_ATTR_FX, SP_ATTR_FY, + SP_ATTR_FR, /* SPMeshPatch */ SP_ATTR_TENSOR, //SP_ATTR_TYPE, diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp index 8b7a22f21..f811f00ad 100644 --- a/src/extension/internal/cairo-render-context.cpp +++ b/src/extension/internal/cairo-render-context.cpp @@ -1245,11 +1245,12 @@ CairoRenderContext::_createPatternForPaintServer(SPPaintServer const *const pain Geom::Point c (rg->cx.computed, rg->cy.computed); Geom::Point f (rg->fx.computed, rg->fy.computed); double r = rg->r.computed; + double fr = rg->fr.computed; if (pbox && SP_GRADIENT(rg)->getUnits() == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX) apply_bbox2user = true; // create radial gradient pattern - pattern = cairo_pattern_create_radial(f[Geom::X], f[Geom::Y], 0, c[Geom::X], c[Geom::Y], r); + pattern = cairo_pattern_create_radial(f[Geom::X], f[Geom::Y], fr, c[Geom::X], c[Geom::Y], r); // add stops for (gint i = 0; unsigned(i) < rg->vector.stops.size(); i++) { diff --git a/src/sp-radial-gradient.cpp b/src/sp-radial-gradient.cpp index 8fb230ba7..7175a8165 100644 --- a/src/sp-radial-gradient.cpp +++ b/src/sp-radial-gradient.cpp @@ -16,6 +16,7 @@ SPRadialGradient::SPRadialGradient() : SPGradient() { this->r.unset(SVGLength::PERCENT, 0.5, 0.5); this->fx.unset(SVGLength::PERCENT, 0.5, 0.5); this->fy.unset(SVGLength::PERCENT, 0.5, 0.5); + this->fr.unset(SVGLength::PERCENT, 0.5, 0.5); } SPRadialGradient::~SPRadialGradient() { @@ -32,6 +33,7 @@ void SPRadialGradient::build(SPDocument *document, Inkscape::XML::Node *repr) { this->readAttr( "r" ); this->readAttr( "fx" ); this->readAttr( "fy" ); + this->readAttr( "fr" ); } /** @@ -89,6 +91,13 @@ void SPRadialGradient::set(unsigned key, gchar const *value) { this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; + case SP_ATTR_FR: + if (!this->fr.read(value)) { + this->fr.unset(SVGLength::PERCENT, 0.5, 0.5); + } + this->requestModified(SP_OBJECT_MODIFIED_FLAG); + break; + default: SPGradient::set(key, value); break; @@ -123,6 +132,10 @@ Inkscape::XML::Node* SPRadialGradient::write(Inkscape::XML::Document *xml_doc, I sp_repr_set_svg_double(repr, "fy", this->fy.computed); } + if ((flags & SP_OBJECT_WRITE_ALL) || this->fr._set) { + sp_repr_set_svg_double(repr, "fr", this->fr.computed); + } + SPGradient::write(xml_doc, repr, flags); return repr; @@ -135,6 +148,7 @@ cairo_pattern_t* SPRadialGradient::pattern_new(cairo_t *ct, Geom::OptRect const Geom::Point center(this->cx.computed, this->cy.computed); double radius = this->r.computed; + double focusr = this->fr.computed; double scale = 1.0; double tolerance = cairo_get_tolerance(ct); @@ -159,8 +173,10 @@ cairo_pattern_t* SPRadialGradient::pattern_new(cairo_t *ct, Geom::OptRect const Geom::Point d(focus - center); Geom::Point d_user(d.length(), 0); Geom::Point r_user(radius, 0); + Geom::Point fr_user(focusr, 0); d_user *= gs2user.withoutTranslation(); r_user *= gs2user.withoutTranslation(); + fr_user *= gs2user.withoutTranslation(); double dx = d_user.x(), dy = d_user.y(); cairo_user_to_device_distance(ct, &dx, &dy); @@ -181,7 +197,7 @@ cairo_pattern_t* SPRadialGradient::pattern_new(cairo_t *ct, Geom::OptRect const } cairo_pattern_t *cp = cairo_pattern_create_radial( - scale * d.x() + center.x(), scale * d.y() + center.y(), 0, + scale * d.x() + center.x(), scale * d.y() + center.y(), focusr, center.x(), center.y(), radius); sp_gradient_pattern_common_setup(cp, this, bbox, opacity); diff --git a/src/sp-radial-gradient.h b/src/sp-radial-gradient.h index f753623b7..f90c8c7a9 100644 --- a/src/sp-radial-gradient.h +++ b/src/sp-radial-gradient.h @@ -25,6 +25,7 @@ public: SVGLength r; SVGLength fx; SVGLength fy; + SVGLength fr; // Focus radius. Added in SVG 2 virtual cairo_pattern_t* pattern_new(cairo_t *ct, Geom::OptRect const &bbox, double opacity); |
