[cairo-bugs] [Bug 40918] Radial gradients misrendered if focus is exactly on the outer circle

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Sat Sep 17 18:27:59 PDT 2011


https://bugs.freedesktop.org/show_bug.cgi?id=40918

--- Comment #15 from Andrea Canciani <ranma42 at gmail.com> 2011-09-17 18:27:57 PDT ---
(In reply to comment #13)
> (In reply to comment #10)
> > It is possible, but the application should be doing it, not cairo (cairo has no
> > means to know whether you wanted the focus point to be inside or outside the
> > circle, it just tries to respect the input).
> > The application could move the focus point slightly inside the outer circle in
> > order to (try to) avoid the rounding issues, but the problem is ill-conditioned
> > when the focus is almost on the outer circle, so the behavior you see is
> > actually the expected one.
> 
> In order to reliably do this, I have to know how large the gradient will be
> when rendered - I have to move the focus point inside the outer circle by about
> half of a screen pixel. But I do not know the pixel size of the gradient when
> creating it.

Do you know the pattern matrix and the target context?
If you know both of them, it should be possible to do this by transforming the
center of the outer circle and the focus point to device space and moving the
transformed focus towards the center of 2*cairo_get_tolerance () units (I would
avoid moving by half a pixel, because it might easily be too much when
rendering to non-raster surfaces).

> 
> I would much prefer if the behavior of Cairo was explicitly defined in this
> case, rather effectively left undefined.

It is not left undefined. The behavior follows the PDF specification, which is
also consistent with PS and HTML canvas and AFAICT with SVG, too. The
documentation should describe the behavior of gradients, but that's true for
linear gradients as well.

> 
> > Anyway, could you please try to describe the extend mode you would like to add
> > and what the behavior for a radial gradient in generic position would be? Would
> > this new extend mode also provide a new rasterization type for other pattern
> > types as well?
> 
> The new extend mode would be identical to CAIRO_EXTEND_PAD for all patterns
> except radial gradients and it would fill the half-plane which is now left
> transparent with the color of the outer circle.

Would this provide a big advantage over choosing the background color?
It looks like the semantic would be the same as PAD using the outer circle
color as the background, which means that it would be much less generic.

(In reply to comment #14)
> (In reply to comment #12)
> > If somebody has a link to document which specifies the aspect of SVG radial
> > gradients?
> > (http://www.w3.org/TR/SVG/pservers.html#RadialGradients doesn't do this, it
> > only specifies how to reduce the parameters to a valid range)
> 
> http://dev.w3.org/SVG/profiles/1.1F2/test/harness/htmlSVGWeb/pservers-grad-13-b.html
> 
> This is the closest I could find. Unfortunately the outermost color in this
> gradient is transparent.

AFAICT it seems safe to assume that nobody specified the rendering aspect of
radial gradients.
The only reason why anybody would choose a different definition from PDF seems
to be that they wanted continuity even when the focus is on the outer circle.

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the cairo-bugs mailing list