cairo::pattern+x86_64 +linux

cairo::pattern_t is the paint with which cairo draws. The primary use of patterns is as the source for all cairo drawing operations, although they can also be used as masks, that is, as the brush too.

A cairo pattern is created by using one of the many constructors, of the form cairo::pattern::create_type() or implicitly through cairo::set_source_type() functions.

Index

Functions

fn add_color_stop_rgb(pattern: *cairo::pattern_t, offset_: f64, red: f64, green: f64, blue: f64) (void | cairo::error);
fn add_color_stop_rgba(pattern: *cairo::pattern_t, offset_: f64, red: f64, green: f64, blue: f64, alpha: f64) (void | cairo::error);
fn create_for_surface(surface: *cairo::surface_t) (*cairo::pattern_t | cairo::error);
fn create_linear(x0: f64, y0: f64, x1: f64, y1: f64) (*cairo::pattern_t | cairo::error);
fn create_mesh() *cairo::pattern_t;
fn create_radial(cx0: f64, cy0: f64, radius0: f64, cx1: f64, cy1: f64, radius1: f64) (*cairo::pattern_t | cairo::error);
fn create_rgb(red: f64, green: f64, blue: f64) (*cairo::pattern_t | cairo::error);
fn create_rgba(red: f64, green: f64, blue: f64, alpha: f64) (*cairo::pattern_t | cairo::error);
fn destroy(pattern: *cairo::pattern_t) void;
fn get_color_stop_count(pattern: *cairo::pattern_t, count: *int) cairo::status_t;
fn get_color_stop_rgba(pattern: *cairo::pattern_t, index: int, offset_: *f64, red: *f64, green: *f64, blue: *f64, alpha: *f64) cairo::status_t;
fn get_extend(pattern: *cairo::pattern_t) cairo::extend_t;
fn get_filter(pattern: *cairo::pattern_t) cairo::filter_t;
fn get_linear_points(pattern: *cairo::pattern_t, x0: *f64, y0: *f64, x1: *f64, y1: *f64) cairo::status_t;
fn get_matrix(pattern: *cairo::pattern_t, matrix: *cairo::matrix_t) void;
fn get_radial_circles(pattern: *cairo::pattern_t, x0: *f64, y0: *f64, r0: *f64, x1: *f64, y1: *f64, r1: *f64) cairo::status_t;
fn get_reference_count(pattern: *cairo::pattern_t) uint;
fn get_rgba(pattern: *cairo::pattern_t, red: *f64, green: *f64, blue: *f64, alpha: *f64) cairo::status_t;
fn get_surface(pattern: *cairo::pattern_t, surface: *cairo::surface_t) cairo::status_t;
fn get_type(pattern: *cairo::pattern_t) cairo::pattern_type_t;
fn reference(pattern: *cairo::pattern_t) *cairo::pattern_t;
fn set_extend(pattern: *cairo::pattern_t, extend: cairo::extend_t) void;
fn set_filter(pattern: *cairo::pattern_t, filter: cairo::filter_t) void;
fn set_matrix(pattern: *cairo::pattern_t, matrix: *const cairo::matrix_t) void;
fn status(pattern: *cairo::pattern_t) cairo::status_t;

Functions

fn add_color_stop_rgb[link]

fn add_color_stop_rgb(pattern: *cairo::pattern_t, offset_: f64, red: f64, green: f64, blue: f64) (void | cairo::error);

Adds an opaque color stop to a gradient pattern. The offset specifies the location along the gradient's control vector. For example, a linear gradient's control vector is from (x0,y0) to (x1,y1) while a radial gradient's control vector is from any point on the start circle to the corresponding point on the end circle.

The color is specified in the same way as in cairo::set_source_rgb.

If two (or more) stops are specified with identical offset values, they will be sorted according to the order in which the stops are added, (stops added earlier will compare less than stops added later). This can be useful for reliably making sharp color transitions instead of the typical blend.

Parameters

fn add_color_stop_rgba[link]

fn add_color_stop_rgba(pattern: *cairo::pattern_t, offset_: f64, red: f64, green: f64, blue: f64, alpha: f64) (void | cairo::error);

Adds a translucent color stop to a gradient pattern. The offset specifies the location along the gradient's control vector. For example, a linear gradient's control vector is from (x0,y0) to (x1,y1) while a radial gradient's control vector is from any point on the start circle to the corresponding point on the end circle.

The color is specified in the same way as in cairo::set_source_rgba.

If two (or more) stops are specified with identical offset values, they will be sorted according to the order in which the stops are added, (stops added earlier will compare less than stops added later). This can be useful for reliably making sharp color transitions instead of the typical blend.

Parameters

fn create_for_surface[link]

fn create_for_surface(surface: *cairo::surface_t) (*cairo::pattern_t | cairo::error);

Creates a new cairo::pattern_t for the given surface.

Returns the newly created cairo::pattern_t if successful, or an cairo::error in case of no memory. The caller owns the returned object and should call cairo::pattern_destroy when finished with it.

fn create_linear[link]

fn create_linear(x0: f64, y0: f64, x1: f64, y1: f64) (*cairo::pattern_t | cairo::error);

Creates a new linear gradient cairo::pattern_t along the line defined by (x0, y0) and (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.

Note: The coordinates here are in pattern space. For a new pattern, pattern space is identical to user space, but the relationship between the spaces can be changed with cairo::pattern::set_matrix.

Parameters

Returns the newly created cairo::pattern_t if successful, or an cairo::error in case of no memory. The caller owns the returned object and should call cairo::pattern_destroy when finished with it.

fn create_mesh[link]

fn create_mesh() *cairo::pattern_t;

XXX: Creates a new mesh pattern.

fn create_radial[link]

fn create_radial(cx0: f64, cy0: f64, radius0: f64, cx1: f64, cy1: f64, radius1: f64) (*cairo::pattern_t | cairo::error);

Creates a new radial gradient cairo::pattern_t between the two circles defined by (cx0, cy0, radius0) and (cx1, cy1, radius1). 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.

Note: The coordinates here are in pattern space. For a new pattern, pattern space is identical to user space, but the relationship between the spaces can be changed with cairo::pattern::set_matrix.

Parameters

Returns the newly created cairo::pattern_t if successful, or an cairo::error in case of no memory. The caller owns the returned object and should call cairo::pattern_destroy when finished with it.

fn create_rgb[link]

fn create_rgb(red: f64, green: f64, blue: f64) (*cairo::pattern_t | cairo::error);

Creates a new cairo::pattern_t corresponding to an opaque color. The color components are floating point numbers in the range 0.0 to 1.0. If the values passed in are outside that range, they will be clamped.

Parameters

Returns the newly created cairo::pattern_t if successful, or an cairo::error in case of no memory. The caller owns the returned object and should call cairo::pattern_destroy when finished with it.

fn create_rgba[link]

fn create_rgba(red: f64, green: f64, blue: f64, alpha: f64) (*cairo::pattern_t | cairo::error);

Creates a new cairo::pattern_t corresponding to a translucent color. The color components are floating point numbers in the range 0.0 to 1.0 If the values passed in are outside that range, they will be clamped.

Parameters

Returns the newly created cairo::pattern_t if successful, or an cairo::error in case of no memory. The caller owns the returned object and should call cairo::pattern_destroy when finished with it.

fn destroy[link]

fn destroy(pattern: *cairo::pattern_t) void;

Decreases the reference count on pattern by one. If the result is zero, then pattern and all associated resources are freed. See cairo::pattern::reference.

fn get_color_stop_count[link]

fn get_color_stop_count(pattern: *cairo::pattern_t, count: *int) cairo::status_t;

XXX: HAREFY Gets the number of color stops specified in the given gradient pattern.

Parameters

Returns CAIRO_STATUS_SUCCESS, or CAIRO_STATUS_PATTERN_TYPE_MISMATCH if pattern is not a gradient pattern.

fn get_color_stop_rgba[link]

fn get_color_stop_rgba(pattern: *cairo::pattern_t, index: int, offset_: *f64, red: *f64, green: *f64, blue: *f64, alpha: *f64) cairo::status_t;

XXX: HAREFY Gets the color and offset information at the given index for a gradient pattern. Values of index range from 0 to n-1 where n is the number returned by cairo::pattern::get_color_stop_count.

Parameters

Returns CAIRO_STATUS_SUCCESS, or CAIRO_STATUS_INVALID_INDEX if index is not valid for the given pattern. If the pattern is not a gradient pattern, CAIRO_STATUS_PATTERN_TYPE_MISMATCH is returned.

fn get_extend[link]

fn get_extend(pattern: *cairo::pattern_t) cairo::extend_t;

Gets the current extend mode for a pattern. See cairo::extend_t for details on the semantics of each extend strategy.

fn get_filter[link]

fn get_filter(pattern: *cairo::pattern_t) cairo::filter_t;

Gets the current filter for a pattern. See cairo::filter_t for details on each filter.

fn get_linear_points[link]

fn get_linear_points(pattern: *cairo::pattern_t, x0: *f64, y0: *f64, x1: *f64, y1: *f64) cairo::status_t;

XXX: HAREFY Gets the gradient endpoints for a linear gradient.

Parameters

Returns CAIRO_STATUS_SUCCESS, or CAIRO_STATUS_PATTERN_TYPE_MISMATCH if pattern is not a linear gradient pattern.

fn get_matrix[link]

fn get_matrix(pattern: *cairo::pattern_t, matrix: *cairo::matrix_t) void;

XXX: HAREFY Stores the pattern's transformation matrix into matrix.

fn get_radial_circles[link]

fn get_radial_circles(pattern: *cairo::pattern_t, x0: *f64, y0: *f64, r0: *f64, x1: *f64, y1: *f64, r1: *f64) cairo::status_t;

XXX: HAREFY Gets the gradient endpoint circles for a radial gradient, each specified as a center coordinate and a radius.

Parameters

Returns CAIRO_STATUS_SUCCESS, or CAIRO_STATUS_PATTERN_TYPE_MISMATCH if pattern is not a radial gradient pattern.

fn get_reference_count[link]

fn get_reference_count(pattern: *cairo::pattern_t) uint;

Returns the current reference count of pattern. If the object is a nil object, 0 will be returned.

fn get_rgba[link]

fn get_rgba(pattern: *cairo::pattern_t, red: *f64, green: *f64, blue: *f64, alpha: *f64) cairo::status_t;

XXX: HAREFY Gets the solid color for a solid color pattern.

Parameters

Returns CAIRO_STATUS_SUCCESS, or CAIRO_STATUS_PATTERN_TYPE_MISMATCH if the pattern is not a solid color pattern.

fn get_surface[link]

fn get_surface(pattern: *cairo::pattern_t, surface: *cairo::surface_t) cairo::status_t;

XXX: HAREFY Gets the surface of a surface pattern. The reference returned in surface is owned by the pattern; the caller should call cairo::surface::reference if the surface is to be retained.

Parameters

Returns CAIRO_STATUS_SUCCESS, or CAIRO_STATUS_PATTERN_TYPE_MISMATCH if the pattern is not a surface pattern.

fn get_type[link]

fn get_type(pattern: *cairo::pattern_t) cairo::pattern_type_t;

Get the pattern's type. See cairo::pattern_type_t for available types.

fn reference[link]

fn reference(pattern: *cairo::pattern_t) *cairo::pattern_t;

Increases the reference count on pattern by one. This prevents pattern from being destroyed until a matching call to cairo::pattern::destroy is made.

Use cairo::pattern::get_reference_count to get the number of references to a cairo::pattern_t.

Returns the referenced cairo::pattern_t.

fn set_extend[link]

fn set_extend(pattern: *cairo::pattern_t, extend: cairo::extend_t) void;

Sets the mode to be used for drawing outside the area of a pattern. See cairo::extend_t for details on the semantics of each extend strategy.

The default extend mode is cairo::extend_t::NONE for surface patterns and cairo::extend_t::PAD for gradient patterns.

fn set_filter[link]

fn set_filter(pattern: *cairo::pattern_t, filter: cairo::filter_t) void;

Sets the filter to be used for resizing when using this pattern. See cairo::filter_t for details on each filter.

Note that you might want to control filtering even when you do not have an explicit cairo::pattern_t object, (for example when using cairo::set_source_surface). In these cases, it is convenient to use cairo::get_source to get access to the pattern that cairo creates implicitly. For example:

cairo::set_source_surface(cr, image, x, y); cairo::pattern::set_filter(cairo::get_source(cr), cairo::filter_t::NEAREST);

fn set_matrix[link]

fn set_matrix(pattern: *cairo::pattern_t, matrix: *const cairo::matrix_t) void;

XXX: HAREFY Sets the pattern's transformation matrix to matrix. This matrix is a transformation from user space to pattern space.

When a pattern is first created it always has the identity matrix for its transformation matrix, which means that pattern space is initially identical to user space.

Important: Please note that the direction of this transformation matrix is from user space to pattern space. This means that if you imagine the flow from a pattern to user space (and on to device space), then coordinates in that flow will be transformed by the inverse of the pattern matrix.

For example, if you want to make a pattern appear twice as large as it does by default the correct code to use is:

cairo::matrix::init_scale(&matrix, 0.5, 0.5); cairo::pattern::set_matrix(pattern, &matrix);

Meanwhile, using values of 2.0 rather than 0.5 in the code above would cause the pattern to appear at half of its default size.

Also, please note the discussion of the user-space locking semantics of cairo::set_source.

fn status[link]

fn status(pattern: *cairo::pattern_t) cairo::status_t;

Checks whether an error has previously occurred for this pattern.