Radial gradients with focus outside outer circle do not rendered correctly

Bug #845153 reported by Ulf Adams on 2011-09-08
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Inkscape
High
Krzysztof Kosinski

Bug Description

Radial gradients don't render correctly if the focus (fx, fy) lies outside the circle with center (cx, cy) and radius r. The SVG spec has this to say:

If the point defined by ‘fx’ and ‘fy’ lies outside the circle defined by ‘cx’, ‘cy’ and ‘r’, then the user agent shall set the focal point to the intersection of the line from (‘cx’, ‘cy’) to (‘fx’, ‘fy’) with the circle defined by ‘cx’, ‘cy’ and ‘r’.

I have attached a sample svg that I created with inkscape, and two screenshots, one for inkscape, and one for chrome (the browser), which appears to render the gradient correctly.

Ulf Adams (ulf-ofahrt) wrote :
Ulf Adams (ulf-ofahrt) wrote :
Ulf Adams (ulf-ofahrt) wrote :
Ulf Adams (ulf-ofahrt) wrote :

I'm using "Inkscape 0.48+devel r" from the Inkscape developers PPA:
https://launchpad.net/~inkscape.dev/+archive/trunk

To be precise, this package is currently installed:
inkscape_0.48+devel+10324+10~natty1_amd64.deb

ScislaC (scislac) wrote :

Not reproduced with 0.48. Reproduced with r10624.

I marked this as high, but it may actually be a cairo bug and not an Inkscape bug. Can someone with a cairo devel build installed test this?

Changed in inkscape:
status: New → Confirmed
importance: Undecided → High
milestone: none → 0.49
ScislaC (scislac) on 2011-09-08
Changed in inkscape:
assignee: nobody → Krzysztof Kosinski (tweenk)
su_v (suv-lp) wrote :

ScislaC wrote:
> Ulf Adams wrote:
>> inkscape_0.48+devel+10324+10~natty1_amd64.deb
> I marked this as high, but it may actually be a cairo bug
> and not an Inkscape bug.

The cairo-rendering branch was only merged in r10326 [1]. OTOH the fact that rsvg-view exposes the same issue as Inkscape trunk (after the merge of the new renderer) might indicate that the issue is not in Inkscape's code but indeed one of cairo's gradient bugs.

Not reproduced with
- Inkscape 0.48.2 (cairo 1.10.2)
- Inkscape 0.48+devel r10313, r10325 (cairo 1.8.10, 1.10.2)
- Squiggle (Batik 1.7)

Reproduced with
- Inkscape cairo-rendering branch r9598 (cairo 1.10.2)
- Inkscape 0.48+devel r10626 (cairo 1.10.2, 1.11.2)
- rsvg-view 2.34.0 (cairo 1.10.2, 1.11.2)

[1] It seems odd to me that the issue was reported for the old renderer (r10324), which I can't reproduce.

tags: added: cairo gradient regression renderer-cairo
su_v (suv-lp) wrote :

Reproduced in Inkscape 0.48.2, cairo 1.10.2:
In cairo-based exports (saving a copy as PDF/PS/EPS or as 'Cairo PNG') current stable exposes the same interpretation of the radial gradient "if the focus (fx, fy) lies outside the circle with center (cx, cy) and radius r" as the new renderer in trunk does on-canvas.

Any chance the package name might be wrong and it's actually the new renderer?

On Fri, Sep 9, 2011 at 7:27 AM, ~suv <email address hidden> wrote:
> Reproduced in Inkscape 0.48.2, cairo 1.10.2:
> In cairo-based exports (saving a copy as PDF/PS/EPS or as 'Cairo PNG') current stable exposes the same interpretation of the radial gradient "if the focus (fx, fy) lies outside the circle with center (cx, cy) and radius r" as the new renderer in trunk does on-canvas.
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/845153
>
> Title:
>  radial gradients not rendered correctly
>
> Status in Inkscape: A Vector Drawing Tool:
>  Confirmed
>
> Bug description:
>  Radial gradients don't render correctly if the focus (fx, fy) lies
>  outside the circle with center (cx, cy) and radius r. The SVG spec has
>  this to say:
>
>  If the point defined by ‘fx’ and ‘fy’ lies outside the circle defined
>  by ‘cx’, ‘cy’ and ‘r’, then the user agent shall set the focal point
>  to the intersection of the line from (‘cx’, ‘cy’) to (‘fx’, ‘fy’) with
>  the circle defined by ‘cx’, ‘cy’ and ‘r’.
>
>  I have attached a sample svg that I created with inkscape, and two
>  screenshots, one for inkscape, and one for chrome (the browser), which
>  appears to render the gradient correctly.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/inkscape/+bug/845153/+subscriptions
>

Ulf: Definitely not fool-proof, but what does Help>About Inkscape say in the top-right corner?

Ulf Adams (ulf-ofahrt) wrote :

It says "Inkscape 0.48+devel r". I can't see more of it.

Ulf Adams (ulf-ofahrt) wrote :

Stupid me, I was looking at the wrong number. It's:
inkscape-trunk_0.48+devel+10626+20~natty1_amd64.deb

I was looking at the inkscape package, not inkscape-trunk.

su_v (suv-lp) wrote :

Could be this upstream cairo issue:

Incorrect radial gradients when focus is outside of outermost circle
https://bugs.freedesktop.org/show_bug.cgi?id=29521

as mentioned by Krzysztof on inkscape-devel:
<http://article.gmane.org/gmane.comp.graphics.inkscape.devel/36697>

Uhh, if I read the pdf spec correctly (I'm not saying that I do), then
it's different from the svg spec in that the focus isn't mapped onto
the circle, which may explain the rendering differences here. This
might be fixed by doing that 'manually' in the inkscape code that sets
up the gradient with cairo.

On Wed, Sep 14, 2011 at 2:29 AM, ~suv <email address hidden> wrote:
> Could be this upstream cairo issue:
>
> Incorrect radial gradients when focus is outside of outermost circle
> https://bugs.freedesktop.org/show_bug.cgi?id=29521
>
> as mentioned by Krzysztof on inkscape-devel:
> <http://article.gmane.org/gmane.comp.graphics.inkscape.devel/36697>
>
> ** Bug watch added: freedesktop.org Bugzilla #29521
>   http://bugs.freedesktop.org/show_bug.cgi?id=29521
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/845153
>
> Title:
>  radial gradients not rendered correctly
>
> Status in Inkscape: A Vector Drawing Tool:
>  Confirmed
>
> Bug description:
>  Radial gradients don't render correctly if the focus (fx, fy) lies
>  outside the circle with center (cx, cy) and radius r. The SVG spec has
>  this to say:
>
>  If the point defined by ‘fx’ and ‘fy’ lies outside the circle defined
>  by ‘cx’, ‘cy’ and ‘r’, then the user agent shall set the focal point
>  to the intersection of the line from (‘cx’, ‘cy’) to (‘fx’, ‘fy’) with
>  the circle defined by ‘cx’, ‘cy’ and ‘r’.
>
>  I have attached a sample svg that I created with inkscape, and two
>  screenshots, one for inkscape, and one for chrome (the browser), which
>  appears to render the gradient correctly.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/inkscape/+bug/845153/+subscriptions
>

This is not a Cairo bug, as it follows the PDF definition of radial gradients. Inkscape has to clip the focal point to the circle by itself.

Krzysztof Kosinski (tweenk) wrote :

I have a fix, but due to numeric precision problems in Cairo, the rendering randomly jumps between the correct one and partial fill with the outer color. Fix depends on this Cairo bug:
https://bugs.freedesktop.org/show_bug.cgi?id=40918

summary: - radial gradients not rendered correctly
+ Radial gradients with focus outside outer circle do not rendered
+ correctly
Changed in inkscape:
status: Confirmed → Triaged

On Thu, Sep 15, 2011 at 8:30 PM, Krzysztof Kosinski
<email address hidden> wrote:
> This is not a Cairo bug, as it follows the PDF definition of radial
> gradients. Inkscape has to clip the focal point to the circle by itself.

I suspect that you won't be able to get that to work reliably - the
PDF spec is fundamentally broken for the case where the focus is on
the circle. You'll have to clip to a slightly smaller circle or the
numerical accuracy will play havok with rendering.

> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/845153
>
> Title:
>  radial gradients not rendered correctly
>
> Status in Inkscape: A Vector Drawing Tool:
>  Confirmed
>
> Bug description:
>  Radial gradients don't render correctly if the focus (fx, fy) lies
>  outside the circle with center (cx, cy) and radius r. The SVG spec has
>  this to say:
>
>  If the point defined by ‘fx’ and ‘fy’ lies outside the circle defined
>  by ‘cx’, ‘cy’ and ‘r’, then the user agent shall set the focal point
>  to the intersection of the line from (‘cx’, ‘cy’) to (‘fx’, ‘fy’) with
>  the circle defined by ‘cx’, ‘cy’ and ‘r’.
>
>  I have attached a sample svg that I created with inkscape, and two
>  screenshots, one for inkscape, and one for chrome (the browser), which
>  appears to render the gradient correctly.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/inkscape/+bug/845153/+subscriptions
>

Krzysztof Kosinski (tweenk) wrote :

Fixed in r10740. I added a hack suggested by Cairo devs, which uses cairo_get_tolerance.

Changed in inkscape:
milestone: 0.49 → none
status: Triaged → Fix Released
Krzysztof Kosinski (tweenk) wrote :

Removing milestone & setting fix released, because this bug was present only in unreleased trunk versions.

su_v (suv-lp) wrote :

Follow-up report (regression AFAICT introduced in r10740):
Bug #970355 "Regression: Radial gradients with offset focal point using 'objectBoundingBox' incorrect (zoom-dependent)"
<https://bugs.launchpad.net/inkscape/+bug/970355>

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.