| Cairo: A Vector Graphics Library |
|---|
cairo_tcairo_t — Drawing contexts. |
typedef cairo_t; cairo_t* cairo_create (void); void cairo_reference (cairo_t *cr); void cairo_destroy (cairo_t *cr); void cairo_save (cairo_t *cr); void cairo_restore (cairo_t *cr); void cairo_copy (cairo_t *dest, cairo_t *src); void cairo_set_target_surface (cairo_t *cr, cairo_surface_t *surface); enum cairo_format_t; void cairo_set_target_image (cairo_t *cr, char *data, cairo_format_t format, int width, int height, int stride); enum cairo_operator_t; void cairo_set_operator (cairo_t *cr, cairo_operator_t op); void cairo_set_rgb_color (cairo_t *cr, double red, double green, double blue); void cairo_set_pattern (cairo_t *cr, cairo_pattern_t *pattern); void cairo_set_alpha (cairo_t *cr, double alpha); void cairo_set_tolerance (cairo_t *cr, double tolerance); enum cairo_fill_rule_t; void cairo_set_fill_rule (cairo_t *cr, cairo_fill_rule_t fill_rule); void cairo_set_line_width (cairo_t *cr, double width); enum cairo_line_cap_t; void cairo_set_line_cap (cairo_t *cr, cairo_line_cap_t line_cap); enum cairo_line_join_t; void cairo_set_line_join (cairo_t *cr, cairo_line_join_t line_join); void cairo_set_dash (cairo_t *cr, double *dashes, int ndash, double offset); void cairo_set_miter_limit (cairo_t *cr, double limit); void cairo_translate (cairo_t *cr, double tx, double ty); void cairo_scale (cairo_t *cr, double sx, double sy); void cairo_rotate (cairo_t *cr, double angle); void cairo_concat_matrix (cairo_t *cr, cairo_matrix_t *matrix); void cairo_set_matrix (cairo_t *cr, cairo_matrix_t *matrix); void cairo_default_matrix (cairo_t *cr); void cairo_identity_matrix (cairo_t *cr); void cairo_transform_point (cairo_t *cr, double *x, double *y); void cairo_transform_distance (cairo_t *cr, double *dx, double *dy); void cairo_inverse_transform_point (cairo_t *cr, double *x, double *y); void cairo_inverse_transform_distance (cairo_t *cr, double *dx, double *dy); void cairo_new_path (cairo_t *cr); void cairo_move_to (cairo_t *cr, double x, double y); void cairo_line_to (cairo_t *cr, double x, double y); void cairo_curve_to (cairo_t *cr, double x1, double y1, double x2, double y2, double x3, double y3); void cairo_arc (cairo_t *cr, double xc, double yc, double radius, double angle1, double angle2); void cairo_arc_negative (cairo_t *cr, double xc, double yc, double radius, double angle1, double angle2); void cairo_rel_move_to (cairo_t *cr, double dx, double dy); void cairo_rel_line_to (cairo_t *cr, double dx, double dy); void cairo_rel_curve_to (cairo_t *cr, double dx1, double dy1, double dx2, double dy2, double dx3, double dy3); void cairo_rectangle (cairo_t *cr, double x, double y, double width, double height); void cairo_close_path (cairo_t *cr); void cairo_stroke (cairo_t *cr); void cairo_fill (cairo_t *cr); void cairo_copy_page (cairo_t *cr); void cairo_show_page (cairo_t *cr); int cairo_in_stroke (cairo_t *cr, double x, double y); int cairo_in_fill (cairo_t *cr, double x, double y); void cairo_stroke_extents (cairo_t *cr, double *x1, double *y1, double *x2, double *y2); void cairo_fill_extents (cairo_t *cr, double *x1, double *y1, double *x2, double *y2); void cairo_init_clip (cairo_t *cr); void cairo_clip (cairo_t *cr); typedef cairo_font_t; cairo_glyph_t; cairo_text_extents_t; cairo_font_extents_t; enum cairo_font_slant_t; enum cairo_font_weight_t; void cairo_select_font (cairo_t *cr, const char *family, cairo_font_slant_t slant, cairo_font_weight_t weight); void cairo_scale_font (cairo_t *cr, double scale); void cairo_transform_font (cairo_t *cr, cairo_matrix_t *matrix); void cairo_show_text (cairo_t *cr, unsigned char *utf8); void cairo_show_glyphs (cairo_t *cr, cairo_glyph_t *glyphs, int num_glyphs); cairo_font_t* cairo_current_font (cairo_t *cr); void cairo_current_font_extents (cairo_t *cr, cairo_font_extents_t *extents); void cairo_set_font (cairo_t *cr, cairo_font_t *font); void cairo_text_extents (cairo_t *cr, unsigned char *utf8, cairo_text_extents_t *extents); void cairo_glyph_extents (cairo_t *cr, cairo_glyph_t *glyphs, int num_glyphs, cairo_text_extents_t *extents); void cairo_text_path (cairo_t *cr, unsigned char *utf8); void cairo_glyph_path (cairo_t *cr, cairo_glyph_t *glyphs, int num_glyphs); void cairo_font_reference (cairo_font_t *font); void cairo_font_destroy (cairo_font_t *font); void cairo_font_glyph_extents (cairo_font_t *font, cairo_matrix_t *font_matrix, cairo_glyph_t *glyphs, int num_glyphs, cairo_text_extents_t *extents); void cairo_show_surface (cairo_t *cr, cairo_surface_t *surface, int width, int height); cairo_operator_t cairo_current_operator (cairo_t *cr); void cairo_current_rgb_color (cairo_t *cr, double *red, double *green, double *blue); cairo_pattern_t* cairo_current_pattern (cairo_t *cr); double cairo_current_alpha (cairo_t *cr); double cairo_current_tolerance (cairo_t *cr); void cairo_current_point (cairo_t *cr, double *x, double *y); cairo_fill_rule_t cairo_current_fill_rule (cairo_t *cr); double cairo_current_line_width (cairo_t *cr); cairo_line_cap_t cairo_current_line_cap (cairo_t *cr); cairo_line_join_t cairo_current_line_join (cairo_t *cr); double cairo_current_miter_limit (cairo_t *cr); void cairo_current_matrix (cairo_t *cr, cairo_matrix_t *matrix); cairo_surface_t* cairo_current_target_surface (cairo_t *cr); void cairo_current_path (cairo_t *cr, cairo_move_to_func_t *move_to, cairo_line_to_func_t *line_to, cairo_curve_to_func_t *curve_to, cairo_close_path_func_t *close_path, void *closure); void cairo_current_path_flat (cairo_t *cr, cairo_move_to_func_t *move_to, cairo_line_to_func_t *line_to, cairo_close_path_func_t *close_path, void *closure); enum cairo_status_t; cairo_status_t cairo_status (cairo_t *cr); const char* cairo_status_string (cairo_t *cr); enum cairo_filter_t; cairo_surface_t* cairo_image_surface_create (cairo_format_t format, int width, int height); cairo_surface_t* cairo_image_surface_create_for_data (char *data, cairo_format_t format, int width, int height, int stride);
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 ships 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.
typedef struct _cairo cairo_t;
A cairo_matrix holds an affine transformation, such as a scale, rotation, or shear, or a combination of those.
void cairo_set_target_surface (cairo_t *cr, cairo_surface_t *surface);
| cr : | |
| surface : |
typedef enum cairo_format {
CAIRO_FORMAT_ARGB32,
CAIRO_FORMAT_RGB24,
CAIRO_FORMAT_A8,
CAIRO_FORMAT_A1
} cairo_format_t;
void cairo_set_target_image (cairo_t *cr, char *data, cairo_format_t format, int width, int height, int stride);
| cr : | |
| data : | |
| format : | |
| width : | |
| height : | |
| stride : |
typedef enum cairo_operator {
CAIRO_OPERATOR_CLEAR,
CAIRO_OPERATOR_SRC,
CAIRO_OPERATOR_DST,
CAIRO_OPERATOR_OVER,
CAIRO_OPERATOR_OVER_REVERSE,
CAIRO_OPERATOR_IN,
CAIRO_OPERATOR_IN_REVERSE,
CAIRO_OPERATOR_OUT,
CAIRO_OPERATOR_OUT_REVERSE,
CAIRO_OPERATOR_ATOP,
CAIRO_OPERATOR_ATOP_REVERSE,
CAIRO_OPERATOR_XOR,
CAIRO_OPERATOR_ADD,
CAIRO_OPERATOR_SATURATE
} cairo_operator_t;
void cairo_set_rgb_color (cairo_t *cr, double red, double green, double blue);
| cr : | |
| red : | |
| green : | |
| blue : |
typedef enum cairo_fill_rule {
CAIRO_FILL_RULE_WINDING,
CAIRO_FILL_RULE_EVEN_ODD
} cairo_fill_rule_t;
void cairo_set_fill_rule (cairo_t *cr, cairo_fill_rule_t fill_rule);
| cr : | |
| fill_rule : |
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 |
void cairo_set_line_cap (cairo_t *cr, cairo_line_cap_t line_cap);
| cr : | |
| line_cap : |
typedef enum cairo_line_join {
CAIRO_LINE_JOIN_MITER,
CAIRO_LINE_JOIN_ROUND,
CAIRO_LINE_JOIN_BEVEL
} cairo_line_join_t;
void cairo_set_line_join (cairo_t *cr, cairo_line_join_t line_join);
| cr : | |
| line_join : |
void cairo_set_dash (cairo_t *cr, double *dashes, int ndash, double offset);
| cr : | |
| dashes : | |
| ndash : | |
| offset : |
void cairo_transform_point (cairo_t *cr, double *x, double *y);
| cr : | |
| x : | |
| y : |
void cairo_transform_distance (cairo_t *cr, double *dx, double *dy);
| cr : | |
| dx : | |
| dy : |
void cairo_inverse_transform_point (cairo_t *cr, double *x, double *y);
| cr : | |
| x : | |
| y : |
void cairo_inverse_transform_distance
(cairo_t *cr,
double *dx,
double *dy);
| cr : | |
| dx : | |
| dy : |
void cairo_curve_to (cairo_t *cr, double x1, double y1, double x2, double y2, double x3, double y3);
| cr : | |
| x1 : | |
| y1 : | |
| x2 : | |
| y2 : | |
| x3 : | |
| y3 : |
void cairo_arc (cairo_t *cr, double xc, double yc, double radius, double angle1, double angle2);
Adds an arc from angle1 to angle2 to the current path. If there is a current point, that point is connected to the start of the arc by a straight line segment. Angles are measured with an angle of 0 along the X axis and an angle of 90 degrees (M_PI radians) along the Y axis, so with the default transformation matrix, positive angles are clockwise. This function gives the arc in the direction of increasing angle; see cairo_arc_negative() to get the arc in the direction of decreasing angle.
A full arc is drawn as a circle. To make an oval arc, you can scale the current transformation matrix by different amounts in the X and Y directions. For example, to draw a full oval in the box given by x, y, width, height:
cairo_save (cr); cairo_translate (x + width / 2., y + height / 2.); cairo_scale (1. / (height / 2.), 1. / (width / 2.)); cairo_arc (cr, 0., 0., 1., 0., 2 * M_PI);
| cr : | a Cairo context |
| xc : | X position of the center of the arc |
| yc : | Y position of the center of the arc |
| radius : | the radius of the arc |
| angle1 : | the start angle, in radians |
| angle2 : | the end angle, in radians |
void cairo_arc_negative (cairo_t *cr, double xc, double yc, double radius, double angle1, double angle2);
Adds an arc from angle1 to angle2 to the current path. The function behaves identically to cairo_arc() except that instead of giving the arc in the direction of increasing angle, it gives the arc in the direction of decreasing angle.
| cr : | a Cairo context |
| xc : | X position of the center of the arc |
| yc : | Y position of the center of the arc |
| radius : | the radius of the arc |
| angle1 : | the start angle, in radians |
| angle2 : | the end angle, in radians |
void cairo_rel_curve_to (cairo_t *cr, double dx1, double dy1, double dx2, double dy2, double dx3, double dy3);
| cr : | |
| dx1 : | |
| dy1 : | |
| dx2 : | |
| dy2 : | |
| dx3 : | |
| dy3 : |
void cairo_rectangle (cairo_t *cr, double x, double y, double width, double height);
| cr : | |
| x : | |
| y : | |
| width : | |
| height : |
void cairo_stroke_extents (cairo_t *cr, double *x1, double *y1, double *x2, double *y2);
| cr : | |
| x1 : | |
| y1 : | |
| x2 : | |
| y2 : |
void cairo_fill_extents (cairo_t *cr, double *x1, double *y1, double *x2, double *y2);
| cr : | |
| x1 : | |
| y1 : | |
| x2 : | |
| y2 : |
typedef struct {
double x_bearing;
double y_bearing;
double width;
double height;
double x_advance;
double y_advance;
} cairo_text_extents_t;
typedef struct {
double ascent;
double descent;
double height;
double max_x_advance;
double max_y_advance;
} cairo_font_extents_t;
typedef enum cairo_font_slant {
CAIRO_FONT_SLANT_NORMAL,
CAIRO_FONT_SLANT_ITALIC,
CAIRO_FONT_SLANT_OBLIQUE
} cairo_font_slant_t;
typedef enum cairo_font_weight {
CAIRO_FONT_WEIGHT_NORMAL,
CAIRO_FONT_WEIGHT_BOLD
} cairo_font_weight_t;
void cairo_select_font (cairo_t *cr, const char *family, cairo_font_slant_t slant, cairo_font_weight_t weight);
| cr : | |
| family : | |
| slant : | |
| weight : |
void cairo_transform_font (cairo_t *cr, cairo_matrix_t *matrix);
| cr : | |
| matrix : |
void cairo_show_glyphs (cairo_t *cr, cairo_glyph_t *glyphs, int num_glyphs);
| cr : | |
| glyphs : | |
| num_glyphs : |
void cairo_current_font_extents (cairo_t *cr, cairo_font_extents_t *extents);
| cr : | |
| extents : |
void cairo_text_extents (cairo_t *cr, unsigned char *utf8, cairo_text_extents_t *extents);
| cr : | |
| utf8 : | |
| extents : |
void cairo_glyph_extents (cairo_t *cr, cairo_glyph_t *glyphs, int num_glyphs, cairo_text_extents_t *extents);
| cr : | |
| glyphs : | |
| num_glyphs : | |
| extents : |
void cairo_glyph_path (cairo_t *cr, cairo_glyph_t *glyphs, int num_glyphs);
| cr : | |
| glyphs : | |
| num_glyphs : |
void cairo_font_glyph_extents (cairo_font_t *font, cairo_matrix_t *font_matrix, cairo_glyph_t *glyphs, int num_glyphs, cairo_text_extents_t *extents);
| font : | |
| font_matrix : | |
| glyphs : | |
| num_glyphs : | |
| extents : |
void cairo_show_surface (cairo_t *cr, cairo_surface_t *surface, int width, int height);
| cr : | |
| surface : | |
| width : | |
| height : |
void cairo_current_rgb_color (cairo_t *cr, double *red, double *green, double *blue);
| cr : | |
| red : | |
| green : | |
| blue : |
void cairo_current_matrix (cairo_t *cr, cairo_matrix_t *matrix);
| cr : | |
| matrix : |
cairo_surface_t* cairo_current_target_surface (cairo_t *cr);
| cr : | |
| Returns : |
void cairo_current_path (cairo_t *cr, cairo_move_to_func_t *move_to, cairo_line_to_func_t *line_to, cairo_curve_to_func_t *curve_to, cairo_close_path_func_t *close_path, void *closure);
| cr : | |
| move_to : | |
| line_to : | |
| curve_to : | |
| close_path : | |
| closure : |
void cairo_current_path_flat (cairo_t *cr, cairo_move_to_func_t *move_to, cairo_line_to_func_t *line_to, cairo_close_path_func_t *close_path, void *closure);
| cr : | |
| move_to : | |
| line_to : | |
| close_path : | |
| closure : |
typedef enum cairo_status {
CAIRO_STATUS_SUCCESS = 0,
CAIRO_STATUS_NO_MEMORY,
CAIRO_STATUS_INVALID_RESTORE,
CAIRO_STATUS_INVALID_POP_GROUP,
CAIRO_STATUS_NO_CURRENT_POINT,
CAIRO_STATUS_INVALID_MATRIX,
CAIRO_STATUS_NO_TARGET_SURFACE,
CAIRO_STATUS_NULL_POINTER
} cairo_status_t;
typedef enum {
CAIRO_FILTER_FAST,
CAIRO_FILTER_GOOD,
CAIRO_FILTER_BEST,
CAIRO_FILTER_NEAREST,
CAIRO_FILTER_BILINEAR,
CAIRO_FILTER_GAUSSIAN
} cairo_filter_t;
cairo_surface_t* cairo_image_surface_create (cairo_format_t format, int width, int height);
| format : | |
| width : | |
| height : | |
| Returns : |
cairo_surface_t* cairo_image_surface_create_for_data (char *data, cairo_format_t format, int width, int height, int stride);
| data : | |
| format : | |
| width : | |
| height : | |
| stride : | |
| Returns : |
| << Part II. Reference | cairo_surface_t >> |