diff options
| author | Tavmjong Bah <tavmjong@free.fr> | 2016-01-09 09:52:04 +0000 |
|---|---|---|
| committer | tavmjong-free <tavmjong@free.fr> | 2016-01-09 09:52:04 +0000 |
| commit | 70e49f7eba8a099a9f5e7f9bfd3ec78f3f1ec1a7 (patch) | |
| tree | aba347cd7a6a0f81329d473900242db8fb3d6a77 /src | |
| parent | Updating libvisio (MS-Visio importer) version. Please use with devlibs>=r58. (diff) | |
| download | inkscape-70e49f7eba8a099a9f5e7f9bfd3ec78f3f1ec1a7.tar.gz inkscape-70e49f7eba8a099a9f5e7f9bfd3ec78f3f1ec1a7.zip | |
Support rendering of radial gradients with the 'fr' attribute. New in SVG 2.
(bzr r14569)
Diffstat (limited to 'src')
| -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 |
6 files changed, 24 insertions, 3 deletions
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); |
