diff options
author | Andrea Canciani <ranma42@gmail.com> | 2011-03-05 10:59:22 +0100 |
---|---|---|
committer | Andrea Canciani <ranma42@gmail.com> | 2011-03-18 09:48:56 +0100 |
commit | 6521bab6e8d8c44e8a790ec6e10ae160ecaf8bc9 (patch) | |
tree | e6285460f371aef9689794791e54b5b08a236daf /src/cairo-pattern.c | |
parent | 426fe6fadffc50f1845b114fc3f41c27f96e8e79 (diff) |
xcb,xlib: Fallback upon generic radial gradients
The RENDER specification requires radial gradients to have the first
circle completely inside the second one, but the error is not actually
generated.
The implementation produces the expected results if either circle
contains the other one, so only fall back in these cases.
Diffstat (limited to 'src/cairo-pattern.c')
-rw-r--r-- | src/cairo-pattern.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c index 000b1ee4..5663a9b4 100644 --- a/src/cairo-pattern.c +++ b/src/cairo-pattern.c @@ -2631,6 +2631,35 @@ _extend_range (double range[2], double value, cairo_bool_t valid) return TRUE; } +/** + * _cairo_radial_pattern_focus_is_inside + * + * Returns %TRUE if and only if the focus point exists and is + * contained in one of the two extreme circles. This condition is + * equivalent to one of the two extreme circles being completely + * contained in the other one. + * + * Note: if the focus is on the border of one of the two circles (in + * which case the circles are tangent in the focus point), it is not + * considered as contained in the circle, hence this function returns + * %FALSE. + * + **/ +cairo_bool_t +_cairo_radial_pattern_focus_is_inside (const cairo_radial_pattern_t *radial) +{ + double cx, cy, cr, dx, dy, dr; + + cx = radial->cd1.center.x; + cy = radial->cd1.center.y; + cr = radial->cd1.radius; + dx = radial->cd2.center.x - cx; + dy = radial->cd2.center.y - cy; + dr = radial->cd2.radius - cr; + + return dx*dx + dy*dy < dr*dr; +} + static void _cairo_radial_pattern_box_to_parameter (const cairo_radial_pattern_t *radial, double x0, double y0, |