| Top |
Cairo drawing utilsCairo drawing utils — Auxiliary and impedance matching functions for Cairo drawing |
| void | gwy_cairo_set_source_rgba () |
| cairo_pattern_t * | gwy_cairo_pattern_create_gradient () |
| void | gwy_cairo_checker_rectangle () |
| void | gwy_cairo_line () |
| void | gwy_cairo_ellipse () |
| void | gwy_cairo_cross () |
| void | gwy_cairo_times () |
| void | gwy_cairo_asterisk () |
| void | gwy_cairo_square () |
| void | gwy_cairo_diamond () |
| void | gwy_cairo_triangle_up () |
| void | gwy_cairo_triangle_down () |
| void | gwy_cairo_triangle_left () |
| void | gwy_cairo_triangle_right () |
| void | gwy_cairo_draw_symbol () |
| void | gwy_cairo_draw_symbols () |
| void | gwy_cairo_draw_line () |
| void | gwy_cairo_region_add_line () |
| void | gwy_cairo_region_add_crectangle () |
| void | gwy_cairo_region_add_erectangle () |
| void | gwy_cairo_region_add_ellipse () |
| void | gwy_cairo_region_add_layout () |
| void | gwy_cairo_draw_or_add_thin_line () |
| void | gwy_cairo_draw_or_add_layout () |
Drawing primitives for simple geometrical shapes such as gwy_cairo_cross() or gwy_cairo_triangle_up() are namely
useful for drawing markes and symbols on graphs because they are visually centered on given coordinates.
Nevertheless, the sizes are given as natural parameters. Use gwy_cairo_draw_symbol() to visually uniform sizes.
void gwy_cairo_set_source_rgba (cairo_t *cr,const GwyRGBA *rgba);
Sets the source patter of a Cairo context to GwyRGBA color.
This is a convenience function that is exactly equivalent to
1 |
cairo_set_source_rgba(cr, rgba->r, rgba->g, rgba->b, rgba->a); |
cairo_pattern_t * gwy_cairo_pattern_create_gradient (GwyGradient *gradient,GtkPositionType towards,gboolean use_alpha);
Creates a linear Cairo pattern corresponding to a false colour gradient.
The pattern is always along the interval [0,1] in either horizontal or vertical direction and either towards 1 or
towards 0, depending on the value of towards
.
void gwy_cairo_checker_rectangle (cairo_t *cr,const GwyRGBA *even,const GwyRGBA *odd,gint width,gint height,gint size);
void gwy_cairo_line (cairo_t *cr,gdouble xfrom,gdouble yfrom,gdouble xto,gdouble yto);
Adds a straight line subpath to a Cairo context.
A new subpath is started, but it is not terminated. Use cairo_new_sub_path() or other subpath-terminating
primitive afterwards if necessary. All parameters are in user coordinates.
This function does cairo_move_to() and cairo_line_to() in a single call, simplifying common line drawing a bit.
void gwy_cairo_ellipse (cairo_t *cr,gdouble x,gdouble y,gdouble xr,gdouble yr);
Adds a closed elliptical subpath to a Cairo context.
A new subpath is started and closed. The ellipse is approximated using Bezier curves, on the other hand, it does not rely on transformations. All parameters are in user coordinates.
void gwy_cairo_cross (cairo_t *cr,gdouble x,gdouble y,gdouble halfside);
Adds a cross-shaped subpath to a Cairo context.
A new subpath is started and terminated. All parameters are in user coordinates.
void gwy_cairo_times (cairo_t *cr,gdouble x,gdouble y,gdouble halfside);
Adds a times-shaped subpath to a Cairo context.
A new subpath is started and terminated. All parameters are in user coordinates.
void gwy_cairo_asterisk (cairo_t *cr,gdouble x,gdouble y,gdouble halfside);
Adds a rightward pointing triangle-shaped subpath to a Cairo context.
A new subpath is started and terminated. All parameters are in user coordinates.
void gwy_cairo_square (cairo_t *cr,gdouble x,gdouble y,gdouble halfside);
Adds a square-shaped subpath to a Cairo context.
A new subpath is started and closed. All parameters are in user coordinates.
void gwy_cairo_diamond (cairo_t *cr,gdouble x,gdouble y,gdouble halfside);
Adds a diamond-shaped subpath to a Cairo context.
A new subpath is started and closed. All parameters are in user coordinates.
void gwy_cairo_triangle_up (cairo_t *cr,gdouble x,gdouble y,gdouble halfside);
Adds an upward pointing triangle-shaped subpath to a Cairo context.
A new subpath is started and closed. All parameters are in user coordinates.
void gwy_cairo_triangle_down (cairo_t *cr,gdouble x,gdouble y,gdouble halfside);
Adds a downward pointing triangle-shaped subpath to a Cairo context.
A new subpath is started and closed. All parameters are in user coordinates.
void gwy_cairo_triangle_left (cairo_t *cr,gdouble x,gdouble y,gdouble halfside);
Adds a leftward pointing triangle-shaped subpath to a Cairo context.
A new subpath is started and closed. All parameters are in user coordinates.
void gwy_cairo_triangle_right (cairo_t *cr,gdouble x,gdouble y,gdouble halfside);
Adds a rightward pointing triangle-shaped subpath to a Cairo context.
A new subpath is started and closed. All parameters are in user coordinates.
void gwy_cairo_draw_symbol (cairo_t *cr,gdouble x,gdouble y,GwySymbolType symbol_type,gdouble size,const GwyRGBA *color);
Draws a graph symbol on a drawable.
Consider using gwy_cairo_draw_symbols() if you are drawing many symbols.
void gwy_cairo_draw_symbols (cairo_t *cr,const GwyXY *coords,guint n,GwySymbolType symbol_type,gdouble size,const GwyRGBA *color);
Draws multiple graph symbols.
void gwy_cairo_draw_line (cairo_t *cr,gdouble x_from,gdouble y_from,gdouble x_to,gdouble y_to,GwyLineStyle line_style,gdouble width,const GwyRGBA *color);
Draws a line segment on a drawable.
cr |
Cairo context. |
|
x_from |
x coordinate of the start point of the line |
|
y_from |
y coordinate of the start point of the line |
|
x_to |
x coordinate of the end point of the line |
|
y_to |
y coordinate of the end point of the line |
|
line_style |
Line style. |
|
width |
Line width. |
|
color |
Line color. If |
[nullable] |
void gwy_cairo_region_add_line (cairo_region_t *region,gdouble xfrom,gdouble yfrom,gdouble xto,gdouble yto,gdouble lw);
Updates a Cairo region by adding the area containing an arbitrary straight line.
void gwy_cairo_region_add_crectangle (cairo_region_t *region,gdouble xc,gdouble yc,gdouble xr,gdouble yr,gdouble lw);
Updates a Cairo region by adding the area containing a rectangle given the centre and half-size.
void gwy_cairo_region_add_erectangle (cairo_region_t *region,gdouble x1,gdouble y1,gdouble x2,gdouble y2,gdouble lw);
Updates a Cairo region by adding the area containing a rectangle given two opposite corners.
void gwy_cairo_region_add_ellipse (cairo_region_t *region,gdouble xc,gdouble yc,gdouble xr,gdouble yr,gdouble lw);
Updates a Cairo region by adding the area containing an ellipse given the centre and semi-axes.
void gwy_cairo_region_add_layout (cairo_region_t *region,PangoLayout *layout,gdouble x,gdouble y);
Updates a Cairo region by adding the area containing a Pango layout.
The area corresponds to the text being drawn with pango_cairo_show_layout() after moving to (x
, y
).
void gwy_cairo_draw_or_add_thin_line (cairo_t *cr,cairo_region_t *region,gdouble xfrom,gdouble yfrom,gdouble xto,gdouble yto);
Draws a line and/or updates a Cairo region to add the line's area.
This is a convenience function wrapping gwy_cairo_line() and gwy_cairo_region_add_line(). Either one or both are
called, depending on which of cr
and region
are non-NULL. The line is must be thin.
void gwy_cairo_draw_or_add_layout (cairo_t *cr,cairo_region_t *region,PangoLayout *layout,gdouble x,gdouble y);
Renders a Pango layout and/or updates a Cairo region to add the text's area.
The coordinates have the effect of cairo_move_to() to the specified point. Normally, this function would not be
called in the middle of drawing a path. Still, be aware the Cairo context position is modified.
This is a convenience function wrapping pango_cairo_show_layout() and gwy_cairo_region_add_layout(). Either one or
both are called, depending on which of cr
and region
are non-NULL.