cairo_t

cairo_t — The cairo drawing context

Synopsis




typedef     cairo_t;
cairo_t*    cairo_create                    (cairo_surface_t *target);
cairo_t*    cairo_reference                 (cairo_t *cr);
void        cairo_destroy                   (cairo_t *cr);
cairo_status_t cairo_status                 (cairo_t *cr);
void        cairo_save                      (cairo_t *cr);
void        cairo_restore                   (cairo_t *cr);
cairo_surface_t* cairo_get_target           (cairo_t *cr);
void        cairo_push_group                (cairo_t *cr);
void        cairo_push_group_with_content   (cairo_t *cr,
                                             cairo_content_t content);
cairo_pattern_t* cairo_pop_group            (cairo_t *cr);
void        cairo_pop_group_to_source       (cairo_t *cr);
cairo_surface_t* cairo_get_group_target     (cairo_t *cr);
void        cairo_set_source_rgb            (cairo_t *cr,
                                             double red,
                                             double green,
                                             double blue);
void        cairo_set_source_rgba           (cairo_t *cr,
                                             double red,
                                             double green,
                                             double blue,
                                             double alpha);
void        cairo_set_source                (cairo_t *cr,
                                             cairo_pattern_t *source);
void        cairo_set_source_surface        (cairo_t *cr,
                                             cairo_surface_t *surface,
                                             double x,
                                             double y);
cairo_pattern_t* cairo_get_source           (cairo_t *cr);
enum        cairo_antialias_t;
void        cairo_set_antialias             (cairo_t *cr,
                                             cairo_antialias_t antialias);
cairo_antialias_t cairo_get_antialias       (cairo_t *cr);
void        cairo_set_dash                  (cairo_t *cr,
                                             double *dashes,
                                             int num_dashes,
                                             double offset);
enum        cairo_fill_rule_t;
void        cairo_set_fill_rule             (cairo_t *cr,
                                             cairo_fill_rule_t fill_rule);
cairo_fill_rule_t cairo_get_fill_rule       (cairo_t *cr);
enum        cairo_line_cap_t;
void        cairo_set_line_cap              (cairo_t *cr,
                                             cairo_line_cap_t line_cap);
cairo_line_cap_t cairo_get_line_cap         (cairo_t *cr);
enum        cairo_line_join_t;
void        cairo_set_line_join             (cairo_t *cr,
                                             cairo_line_join_t line_join);
cairo_line_join_t cairo_get_line_join       (cairo_t *cr);
void        cairo_set_line_width            (cairo_t *cr,
                                             double width);
double      cairo_get_line_width            (cairo_t *cr);
void        cairo_set_miter_limit           (cairo_t *cr,
                                             double limit);
double      cairo_get_miter_limit           (cairo_t *cr);
enum        cairo_operator_t;
void        cairo_set_operator              (cairo_t *cr,
                                             cairo_operator_t op);
cairo_operator_t cairo_get_operator         (cairo_t *cr);
void        cairo_set_tolerance             (cairo_t *cr,
                                             double tolerance);
double      cairo_get_tolerance             (cairo_t *cr);
void        cairo_clip                      (cairo_t *cr);
void        cairo_clip_preserve             (cairo_t *cr);
void        cairo_reset_clip                (cairo_t *cr);
void        cairo_fill                      (cairo_t *cr);
void        cairo_fill_preserve             (cairo_t *cr);
void        cairo_fill_extents              (cairo_t *cr,
                                             double *x1,
                                             double *y1,
                                             double *x2,
                                             double *y2);
cairo_bool_t cairo_in_fill                  (cairo_t *cr,
                                             double x,
                                             double y);
void        cairo_mask                      (cairo_t *cr,
                                             cairo_pattern_t *pattern);
void        cairo_mask_surface              (cairo_t *cr,
                                             cairo_surface_t *surface,
                                             double surface_x,
                                             double surface_y);
void        cairo_paint                     (cairo_t *cr);
void        cairo_paint_with_alpha          (cairo_t *cr,
                                             double alpha);
void        cairo_stroke                    (cairo_t *cr);
void        cairo_stroke_preserve           (cairo_t *cr);
void        cairo_stroke_extents            (cairo_t *cr,
                                             double *x1,
                                             double *y1,
                                             double *x2,
                                             double *y2);
cairo_bool_t cairo_in_stroke                (cairo_t *cr,
                                             double x,
                                             double y);
void        cairo_copy_page                 (cairo_t *cr);
void        cairo_show_page                 (cairo_t *cr);

Description

cairo_t is the main object used when drawing with cairo. To draw with cairo, you create a cairo_t, set the target surface, and drawing options for the cairo_t, create shapes with functions like cairo_move_to() and cairo_line_to(), and then draw shapes with cairo_stroke() or cairo_fill().

cairo_t's can be pushed to a stack via cairo_save(). They may then safely be changed, without loosing the current state. Use cairo_restore() to restore to the saved state.

Details

cairo_t

typedef struct _cairo cairo_t;

A cairo_t contains the current state of the rendering device, including coordinates of yet to be drawn shapes.


cairo_create ()

cairo_t*    cairo_create                    (cairo_surface_t *target);

cairo_reference ()

cairo_t*    cairo_reference                 (cairo_t *cr);

cairo_destroy ()

void        cairo_destroy                   (cairo_t *cr);

cairo_status ()

cairo_status_t cairo_status                 (cairo_t *cr);

cairo_save ()

void        cairo_save                      (cairo_t *cr);

cairo_restore ()

void        cairo_restore                   (cairo_t *cr);

cairo_get_target ()

cairo_surface_t* cairo_get_target           (cairo_t *cr);

cairo_push_group ()

void        cairo_push_group                (cairo_t *cr);

Since 1.2


cairo_push_group_with_content ()

void        cairo_push_group_with_content   (cairo_t *cr,
                                             cairo_content_t content);

Since 1.2


cairo_pop_group ()

cairo_pattern_t* cairo_pop_group            (cairo_t *cr);

Since 1.2


cairo_pop_group_to_source ()

void        cairo_pop_group_to_source       (cairo_t *cr);

Since 1.2


cairo_get_group_target ()

cairo_surface_t* cairo_get_group_target     (cairo_t *cr);

Since 1.2


cairo_set_source_rgb ()

void        cairo_set_source_rgb            (cairo_t *cr,
                                             double red,
                                             double green,
                                             double blue);

cairo_set_source_rgba ()

void        cairo_set_source_rgba           (cairo_t *cr,
                                             double red,
                                             double green,
                                             double blue,
                                             double alpha);

cairo_set_source ()

void        cairo_set_source                (cairo_t *cr,
                                             cairo_pattern_t *source);

cairo_set_source_surface ()

void        cairo_set_source_surface        (cairo_t *cr,
                                             cairo_surface_t *surface,
                                             double x,
                                             double y);

cairo_get_source ()

cairo_pattern_t* cairo_get_source           (cairo_t *cr);

enum cairo_antialias_t

typedef enum _cairo_antialias {
    CAIRO_ANTIALIAS_DEFAULT,
    CAIRO_ANTIALIAS_NONE,
    CAIRO_ANTIALIAS_GRAY,
    CAIRO_ANTIALIAS_SUBPIXEL
} cairo_antialias_t;

Specifies the type of antialiasing to do when rendering text or shapes.

CAIRO_ANTIALIAS_DEFAULT Use the default antialiasing for the subsystem and target device
CAIRO_ANTIALIAS_NONE Use a bilevel alpha mask
CAIRO_ANTIALIAS_GRAY Perform single-color antialiasing (using shades of gray for black text on a white background, for example).
CAIRO_ANTIALIAS_SUBPIXEL Perform antialiasing by taking advantage of the order of subpixel elements on devices such as LCD panels

cairo_set_antialias ()

void        cairo_set_antialias             (cairo_t *cr,
                                             cairo_antialias_t antialias);

cairo_get_antialias ()

cairo_antialias_t cairo_get_antialias       (cairo_t *cr);

cairo_set_dash ()

void        cairo_set_dash                  (cairo_t *cr,
                                             double *dashes,
                                             int num_dashes,
                                             double offset);

enum cairo_fill_rule_t

typedef enum _cairo_fill_rule {
    CAIRO_FILL_RULE_WINDING,
    CAIRO_FILL_RULE_EVEN_ODD
} cairo_fill_rule_t;

cairo_fill_rule_t is used to select how paths are filled. For both fill rules, whether or not a point is included in the fill is determined by taking a ray from that point to infinity and looking at intersections with the path. The ray can be in any direction, as long as it doesn't pass through the end point of a segment or have a tricky intersection such as intersecting tangent to the path. (Note that filling is not actually implemented in this way. This is just a description of the rule that is applied.)

CAIRO_FILL_RULE_WINDING If the path crosses the ray from left-to-right, counts +1. If the path crosses the ray from right to left, counts -1. (Left and right are determined from the perspective of looking along the ray from the starting point.) If the total count is non-zero, the point will be filled.
CAIRO_FILL_RULE_EVEN_ODD Counts the total number of intersections, without regard to the orientation of the contour. If the total number of intersections is odd, the point will be filled.

cairo_set_fill_rule ()

void        cairo_set_fill_rule             (cairo_t *cr,
                                             cairo_fill_rule_t fill_rule);

cairo_get_fill_rule ()

cairo_fill_rule_t cairo_get_fill_rule       (cairo_t *cr);

enum cairo_line_cap_t

typedef enum _cairo_line_cap {
    CAIRO_LINE_CAP_BUTT,
    CAIRO_LINE_CAP_ROUND,
    CAIRO_LINE_CAP_SQUARE
} cairo_line_cap_t;

enumeration for style of line-endings

CAIRO_LINE_CAP_BUTT start(stop) the line exactly at the start(end) point
CAIRO_LINE_CAP_ROUND use a round ending, the center of the circle is the end point
CAIRO_LINE_CAP_SQUARE use squared ending, the center of the square is the end point

cairo_set_line_cap ()

void        cairo_set_line_cap              (cairo_t *cr,
                                             cairo_line_cap_t line_cap);

cairo_get_line_cap ()

cairo_line_cap_t cairo_get_line_cap         (cairo_t *cr);

enum cairo_line_join_t

typedef enum _cairo_line_join {
    CAIRO_LINE_JOIN_MITER,
    CAIRO_LINE_JOIN_ROUND,
    CAIRO_LINE_JOIN_BEVEL
} cairo_line_join_t;


cairo_set_line_join ()

void        cairo_set_line_join             (cairo_t *cr,
                                             cairo_line_join_t line_join);

cairo_get_line_join ()

cairo_line_join_t cairo_get_line_join       (cairo_t *cr);

cairo_set_line_width ()

void        cairo_set_line_width            (cairo_t *cr,
                                             double width);

cairo_get_line_width ()

double      cairo_get_line_width            (cairo_t *cr);

cairo_set_miter_limit ()

void        cairo_set_miter_limit           (cairo_t *cr,
                                             double limit);

cairo_get_miter_limit ()

double      cairo_get_miter_limit           (cairo_t *cr);

enum cairo_operator_t

typedef enum _cairo_operator {
    CAIRO_OPERATOR_CLEAR,

    CAIRO_OPERATOR_SOURCE,
    CAIRO_OPERATOR_OVER,
    CAIRO_OPERATOR_IN,
    CAIRO_OPERATOR_OUT,
    CAIRO_OPERATOR_ATOP,

    CAIRO_OPERATOR_DEST,
    CAIRO_OPERATOR_DEST_OVER,
    CAIRO_OPERATOR_DEST_IN,
    CAIRO_OPERATOR_DEST_OUT,
    CAIRO_OPERATOR_DEST_ATOP,

    CAIRO_OPERATOR_XOR,
    CAIRO_OPERATOR_ADD,
    CAIRO_OPERATOR_SATURATE
} cairo_operator_t;


cairo_set_operator ()

void        cairo_set_operator              (cairo_t *cr,
                                             cairo_operator_t op);

cairo_get_operator ()

cairo_operator_t cairo_get_operator         (cairo_t *cr);

cairo_set_tolerance ()

void        cairo_set_tolerance             (cairo_t *cr,
                                             double tolerance);

cairo_get_tolerance ()

double      cairo_get_tolerance             (cairo_t *cr);

cairo_clip ()

void        cairo_clip                      (cairo_t *cr);

cairo_clip_preserve ()

void        cairo_clip_preserve             (cairo_t *cr);

cairo_reset_clip ()

void        cairo_reset_clip                (cairo_t *cr);

cairo_fill ()

void        cairo_fill                      (cairo_t *cr);

cairo_fill_preserve ()

void        cairo_fill_preserve             (cairo_t *cr);

cairo_fill_extents ()

void        cairo_fill_extents              (cairo_t *cr,
                                             double *x1,
                                             double *y1,
                                             double *x2,
                                             double *y2);

cairo_in_fill ()

cairo_bool_t cairo_in_fill                  (cairo_t *cr,
                                             double x,
                                             double y);

cairo_mask ()

void        cairo_mask                      (cairo_t *cr,
                                             cairo_pattern_t *pattern);

cairo_mask_surface ()

void        cairo_mask_surface              (cairo_t *cr,
                                             cairo_surface_t *surface,
                                             double surface_x,
                                             double surface_y);

cairo_paint ()

void        cairo_paint                     (cairo_t *cr);

cairo_paint_with_alpha ()

void        cairo_paint_with_alpha          (cairo_t *cr,
                                             double alpha);

cairo_stroke ()

void        cairo_stroke                    (cairo_t *cr);

cairo_stroke_preserve ()

void        cairo_stroke_preserve           (cairo_t *cr);

cairo_stroke_extents ()

void        cairo_stroke_extents            (cairo_t *cr,
                                             double *x1,
                                             double *y1,
                                             double *x2,
                                             double *y2);

cairo_in_stroke ()

cairo_bool_t cairo_in_stroke                (cairo_t *cr,
                                             double x,
                                             double y);

cairo_copy_page ()

void        cairo_copy_page                 (cairo_t *cr);

cairo_show_page ()

void        cairo_show_page                 (cairo_t *cr);