[cairo] add solid/gradient pattern info getters

Vladimir Vukicevic vladimirv at gmail.com
Wed Sep 13 16:18:07 PDT 2006


The attached patch adds 4 new API methods:

 cairo_status_t
cairo_solid_pattern_get_color (cairo_pattern_t *pattern,
			       double *r, double *g, double *b, double *a);

cairo_status_t
cairo_gradient_pattern_get_color_stop (cairo_pattern_t *pattern,
				       int index, double *offset,
				       double *r, double *g, double *b, double *a);
cairo_status_t
cairo_linear_gradient_pattern_get_endpoints (cairo_pattern_t *pattern,
					     double *x0, double *y0,
					     double *x1, double *y1);

cairo_status_t
cairo_linear_gradient_pattern_get_endpoints (cairo_pattern_t *pattern,
					     double *x0, double *y0, double *r0,
					     double *x1, double *y1, double *r1);

They all return CAIRO_STATUS_PATTERN_TYPE_MISMATCH on error.  The only
oddball here is get_color_stop, where the expected usage is to start
index at 0 and keep incrementing it until the function returns
CAIRO_STATUS_INVALID_INDEX (a new error code).  This seemed simpler
than having an explicit getter for the number of color stops, or for
doing some kind of bulk dump of the color stop data (e.g. something
like get_color_stops (int *num_values, double *values) that will
return the # of doubles needed in num_values if values is null, and
will fill values with 'offset r g b a' chunks).

Let me know if this looks ok to commit.

    - Vlad


More information about the cairo mailing list