_cairo_image_data_set_radial (cairo_pattern_t *pattern, double offset_x, double offset_y, int *pixels, int width, int height)
_cairo_image_data_set_radial (cairo_radial_pattern_t *pattern, double		     offset_x, double		     offset_y, uint32_t		     *pixels, int		     width, int		     height)
_cairo_image_data_set_radial (cairo_pattern_t *pattern,			      double offset_x,			      double offset_y,			      int *pixels,			      int width,			      int height){    int x, y, aligned_circles;    cairo_point_double_t c0, c1;    double px, py, ex, ey;    double a, b, c, d, tx, ty;    double r0, r1, c0_e_x, c0_e_y, c0_e, c1_e_x, c1_e_y, c1_e,	c0_c1_x, c0_c1_y, c0_c1, angle_c0, c1_y, y_x, c0_y, c0_x, r1_2,	denumerator, fraction, factor;    cairo_shader_op_t op;    _cairo_pattern_shader_init (pattern, &op);    c0.x = pattern->u.radial.center0.x;    c0.y = pattern->u.radial.center0.y;    r0 = pattern->u.radial.radius0;    c1.x = pattern->u.radial.center1.x;    c1.y = pattern->u.radial.center1.y;    r1 =  pattern->u.radial.radius1;    if (c0.x != c1.x || c0.y != c1.y) {	aligned_circles = 0;	c0_c1_x = c1.x - c0.x;	c0_c1_y = c1.y - c0.y;	c0_c1 = sqrt (c0_c1_x * c0_c1_x + c0_c1_y * c0_c1_y);	r1_2 = r1 * r1;    } else {	aligned_circles = 1;	r1 = 1.0 / (r1 - r0);	r1_2 = c0_c1 = 0.0; /* shut up compiler */    }    cairo_matrix_get_affine (&pattern->matrix, &a, &b, &c, &d, &tx, &ty);    for (y = 0; y < height; y++) {	for (x = 0; x < width; x++) {	    px = x + offset_x;	    py = y + offset_y;			    /* transform fragment */	    ex = a * px + c * py + tx;	    ey = b * px + d * py + ty;	    if (aligned_circles) {		ex = ex - c1.x;		ey = ey - c1.y;		factor = (sqrt (ex * ex + ey * ey) - r0) * r1;	    } else {	    /*	                y         (ex, ey)               c0 -------------------+---------- x                  \     |                  __--                   \    |              __--                    \   |          __--                     \  |      __-- r1                      \ |  __--                      c1 --	       We need to calulate distance c0->x; the distance from	       the inner circle center c0, through fragment position	       (ex, ey) to point x where it crosses the outer circle.	       From points c0, c1 and (ex, ey) we get angle C0. With	       angle C0 we calculate distance c1->y and c0->y and by	       knowing c1->y and r1, we also know y->x. Adding y->x to	       c0->y gives us c0->x. The gradient offset can then be	       calculated as:	       	       offset = (c0->e - r0) / (c0->x - r0)	       	       */		c0_e_x = ex - c0.x;		c0_e_y = ey - c0.y;		c0_e = sqrt (c0_e_x * c0_e_x + c0_e_y * c0_e_y);		c1_e_x = ex - c1.x;		c1_e_y = ey - c1.y;		c1_e = sqrt (c1_e_x * c1_e_x + c1_e_y * c1_e_y);		denumerator = -2.0 * c0_e * c0_c1;				if (denumerator != 0.0) {		    fraction = (c1_e * c1_e - c0_e * c0_e - c0_c1 * c0_c1) /			denumerator;		    if (fraction > 1.0)			fraction = 1.0;		    else if (fraction < -1.0)			fraction = -1.0;		    		    angle_c0 = acos (fraction);		    		    c0_y = cos (angle_c0) * c0_c1;		    c1_y = sin (angle_c0) * c0_c1;		    		    y_x = sqrt (r1_2 - c1_y * c1_y);		    c0_x = y_x + c0_y;		    		    factor = (c0_e - r0) / (c0_x - r0);		} else		    factor = -r0;	    }	    _cairo_pattern_calc_color_at_pixel (&op, factor * 65536, pixels++);	}    }}