[cairo] Radii of radial gradients
KUROSAWA, Takeshi
taken.spc at gmail.com
Fri Feb 9 03:30:33 PST 2007
Hi,
I tried the radial gradients with cairo 1.3.13.
The following code generates an image(*1) I unexpected.
pat = cairo_pattern_create_radial (45.0, 45.0, 10.0, 50.0, 50.0, 30.0);
cairo_pattern_add_color_stop_rgba (pat, 0, 1, 1, 1, 1);
cairo_pattern_add_color_stop_rgba (pat, 0.9, 0, 0, 0, 1);
cairo_pattern_add_color_stop_rgba (pat, 1, 0, 0, 0, 0);
cairo_rectangle (cr, 0, 0, 150.0, 150.0);
cairo_set_source (cr, pat);
cairo_fill (cr);
cairo_destroy_pattern (pat);
I expected the radius arguments of the |cairo_pattern_create_radial|
(i.e. 10.0 and 30.0) conform to the radii of the circles.
But, in the result image, the each radius seems to conform to a side
of cyclic quadrilateral of the each circle.
# but not exactly
Therefore, I have a question.
Is it a behavior as per spec of a bug?
Full of the code is following
#include <cairo.h>
#define WIDTH 150
#define HEIGHT 150
#define STRIDE (WIDTH * 4)
unsigned char image[STRIDE*HEIGHT];
int
main (void)
{
cairo_surface_t *surface;
cairo_t *cr;
cairo_pattern_t *pat;
surface = cairo_image_surface_create_for_data (image, CAIRO_FORMAT_ARGB32,
WIDTH, HEIGHT, STRIDE);
cr = cairo_create (surface);
pat = cairo_pattern_create_radial (45.0, 45.0, 10.0, 50.0, 50.0, 30.0);
cairo_pattern_add_color_stop_rgba (pat, 0, 1, 1, 1, 1);
cairo_pattern_add_color_stop_rgba (pat, 0.9, 0, 0, 0, 1);
cairo_pattern_add_color_stop_rgba (pat, 1, 0, 0, 0, 0);
cairo_rectangle (cr, 0, 0, 150.0, 150.0);
cairo_set_source (cr, pat);
cairo_fill (cr);
cairo_pattern_destroy (pat);
/* draw rects that expected circumscribed quadrangles of the
gradient circles. */
cairo_set_source_rgba (cr, 0, 0, 1, 0.5);
cairo_rectangle (cr, 35, 35, 20, 20);
cairo_rectangle (cr, 20, 20, 60, 60);
cairo_stroke (cr);
cairo_surface_write_to_png (surface, "cairo_radial_gradient.png");
cairo_destroy (cr);
cairo_surface_destroy (surface);
return 0;
}
*1: I've attached it to this mail.
--
KUROSAWA, Takeshi - http://taken.s101.xrea.com/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cairo_radial_gradient.png
Type: image/png
Size: 5626 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20070209/9a2faaa4/cairo_radial_gradient.png
More information about the cairo
mailing list