[cairo] (no subject)

Andrea Canciani ranma42 at gmail.com
Fri Jul 10 09:54:49 PDT 2015


On Fri, Jul 10, 2015 at 4:21 PM, Roman Goldov <goldov1 at yandex.ru> wrote:

> I am a new user of GTK+ and of Cairo. That is why I would appreciate
> detailed answers for my questions.
>
> From the manual:
> "cairo_pattern_create_linear(x0,y0,x1,y1) -  Before using the gradient
> pattern, a number of color stops should be defined using
> cairo_pattern_add_color_stop_rgb() or cairo_pattern_add_color_stop_rgba()."
>
> do i understand corerectly that this function is a general function - that
> is it says only to create a linear gradient
> between (x0,y0) and (x1,y1) points, and the colors are defined by, for
> example, cairo_pattern_add_color_stop_rgb()
> function ?
>

Yes, the cairo_pattern_create_linear() function creates a pattern whose
colors are chosen calling cairo_pattern_add_color_stop_rgb[a]().
The linear gradient is obtained by projecting all of the points of the
plane (or, equivalently, by looking for the nearest point) to the
(infinite) line passing through (x0,y0) and (x1,y1). Each of these point is
associated with a parameter which varies from 0 to 1 along the segment that
defines the line.
The color stops define the color in the [0,1] range.
For values outside of the [0,1] range, a extend mode is applied
http://cairographics.org/manual/cairo-cairo-pattern-t.html#cairo-extend-t.


>
> cairo_pattern_add_color_stop_rgb (cairo_pattern_t *pattern, double offset,
> double red, double green, double blue) -
> whst does "offset" mean in terms of the colors? is it a number ? in which
> range it is varied ?
>

The extremes (x0,y0) and (x1,y1) are respectively at offset 0 and 1.

I hope this helps you (we should definitely improve the documentation,
suggestions and patches are welcome ;) ).

Andrea


>
> Thank you.
> --
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20150710/e77b4ba6/attachment.html>


More information about the cairo mailing list