MeshPattern

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 Pattern.createType

or implicitly through cairo_set_source_type() functions.

Constructors

this
this(cairo_pattern_t* cairo_pattern)

Sets our main struct and passes it to the parent class

this
this()

Members

Functions

beginPatch
void beginPatch()

Begin a patch in a mesh pattern. After calling this function, the patch shape should be defined with MeshPattern.moveTo, MeshPattern.lineTo and MeshPattern.curveTo. After defining the patch, MeshPattern.endPatch must be called before using pattern as a source or mask. Note: If pattern is not a mesh pattern then pattern will be put into an error status with a status of CAIRO_STATUS_PATTERN_TYPE_MISMATCH. If pattern already has a current patch, it will be put into an error status with a status of CAIRO_STATUS_INVALID_MESH_CONSTRUCTION. Since 1.12

curveTo
void curveTo(double x1, double y1, double x2, double y2, double x3, double y3)

Adds a cubic Bézier spline to the current patch from the current point to position (x3, y3) in pattern-space coordinates, using (x1, y1) and (x2, y2) as the control points. If the current patch has no current point before the call to MeshPattern.curveTo, this function will behave as if preceded by a call to cairo_mesh_pattern_move_to(pattern, x1, y1). After this call the current point will be (x3, y3). Note: If pattern is not a mesh pattern then pattern will be put into an error status with a status of CAIRO_STATUS_PATTERN_TYPE_MISMATCH. If pattern has no current patch or the current patch already has 4 sides, pattern will be put into an error status with a status of CAIRO_STATUS_INVALID_MESH_CONSTRUCTION. Since 1.12

endPatch
void endPatch()

Indicates the end of the current patch in a mesh pattern. If the current patch has less than 4 sides, it is closed with a straight line from the current point to the first point of the patch as if MeshPattern.lineTo was used. Note: If pattern is not a mesh pattern then pattern will be put into an error status with a status of CAIRO_STATUS_PATTERN_TYPE_MISMATCH. If pattern has no current patch or the current patch has no current point, pattern will be put into an error status with a status of CAIRO_STATUS_INVALID_MESH_CONSTRUCTION. Since 1.12

getControlPoint
cairo_status_t getControlPoint(uint patchNum, uint pointNum, double x, double y)

Gets the control point point_num of patch patch_num for a mesh pattern. patch_num can range 0 to 1 less than the number returned by MeshPattern.getPatchCount. Valid values for point_num are from 0 to 3 and identify the control points as explained in Pattern.createMesh. Since 1.12

getCornerColorRgba
cairo_status_t getCornerColorRgba(uint patchNum, uint cornerNum, double red, double green, double blue, double alpha)

Gets the color information in corner corner_num of patch patch_num for a mesh pattern. patch_num can range 0 to 1 less than the number returned by MeshPattern.getPatchCount. Valid values for corner_num are from 0 to 3 and identify the corners as explained in Pattern.createMesh. Since 1.12

getMeshPatternStruct
cairo_pattern_t* getMeshPatternStruct()

Get the main Gtk struct

getPatchCount
cairo_status_t getPatchCount(uint count)

Gets the number of patches specified in the given mesh pattern. The number only includes patches which have been finished by calling MeshPattern.endPatch. For example it will be 0 during the definition of the first patch. Since 1.12

getPath
cairo_path_t* getPath(uint patchNum)

Gets path defining the patch patch_num for a mesh pattern. patch_num can range 0 to 1 less than the number returned by MeshPattern.getPatchCount. Since 1.12

getStruct
void* getStruct()

the main Gtk struct as a void*

lineTo
void lineTo(double x, double y)

Adds a line to the current patch from the current point to position (x, y) in pattern-space coordinates. If there is no current point before the call to MeshPattern.lineTo this function will behave as cairo_mesh_pattern_move_to(pattern, x, y). After this call the current point will be (x, y). Note: If pattern is not a mesh pattern then pattern will be put into an error status with a status of CAIRO_STATUS_PATTERN_TYPE_MISMATCH. If pattern has no current patch or the current patch already has 4 sides, pattern will be put into an error status with a status of CAIRO_STATUS_INVALID_MESH_CONSTRUCTION. Since 1.12

moveTo
void moveTo(double x, double y)

Define the first point of the current patch in a mesh pattern. After this call the current point will be (x, y). Note: If pattern is not a mesh pattern then pattern will be put into an error status with a status of CAIRO_STATUS_PATTERN_TYPE_MISMATCH. If pattern has no current patch or the current patch already has at least one side, pattern will be put into an error status with a status of CAIRO_STATUS_INVALID_MESH_CONSTRUCTION. Since 1.12

setControlPoint
void setControlPoint(uint pointNum, double x, double y)

Set an internal control point of the current patch. Valid values for point_num are from 0 to 3 and identify the control points as explained in Pattern.createMesh. Note: If pattern is not a mesh pattern then pattern will be put into an error status with a status of CAIRO_STATUS_PATTERN_TYPE_MISMATCH. If point_num is not valid, pattern will be put into an error status with a status of CAIRO_STATUS_INVALID_INDEX. If pattern has no current patch, pattern will be put into an error status with a status of CAIRO_STATUS_INVALID_MESH_CONSTRUCTION. Since 1.12

setCornerColorRgb
void setCornerColorRgb(uint cornerNum, double red, double green, double blue)

Sets the color of a corner of the current patch in a mesh pattern. The color is specified in the same way as in cairo_set_source_rgb(). Valid values for corner_num are from 0 to 3 and identify the corners as explained in Pattern.createMesh. Note: If pattern is not a mesh pattern then pattern will be put into an error status with a status of CAIRO_STATUS_PATTERN_TYPE_MISMATCH. If corner_num is not valid, pattern will be put into an error status with a status of CAIRO_STATUS_INVALID_INDEX. If pattern has no current patch, pattern will be put into an error status with a status of CAIRO_STATUS_INVALID_MESH_CONSTRUCTION. Since 1.12

setCornerColorRgba
void setCornerColorRgba(uint cornerNum, double red, double green, double blue, double alpha)

Sets the color of a corner of the current patch in a mesh pattern. The color is specified in the same way as in cairo_set_source_rgba(). Valid values for corner_num are from 0 to 3 and identify the corners as explained in Pattern.createMesh. Note: If pattern is not a mesh pattern then pattern will be put into an error status with a status of CAIRO_STATUS_PATTERN_TYPE_MISMATCH. If corner_num is not valid, pattern will be put into an error status with a status of CAIRO_STATUS_INVALID_INDEX. If pattern has no current patch, pattern will be put into an error status with a status of CAIRO_STATUS_INVALID_MESH_CONSTRUCTION. Since 1.12

Variables

cairo_pattern
cairo_pattern_t* cairo_pattern;

the main Gtk struct

Inherited Members

From Pattern

cairo_pattern
cairo_pattern_t* cairo_pattern;

the main Gtk struct

getPatternStruct
cairo_pattern_t* getPatternStruct()

Get the main Gtk struct

getStruct
void* getStruct()

the main Gtk struct as a void*

addColorStopRgb
void addColorStopRgb(double offset, double red, double green, double blue)

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. Note: If the pattern is not a gradient pattern, (eg. a linear or radial pattern), then the pattern will be put into an error status with a status of CAIRO_STATUS_PATTERN_TYPE_MISMATCH. Since 1.0

addColorStopRgba
void addColorStopRgba(double offset, double red, double green, double blue, double alpha)

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. Note: If the pattern is not a gradient pattern, (eg. a linear or radial pattern), then the pattern will be put into an error status with a status of CAIRO_STATUS_PATTERN_TYPE_MISMATCH. Since 1.0

getColorStopCount
cairo_status_t getColorStopCount(int count)

Gets the number of color stops specified in the given gradient pattern. Since 1.4

getColorStopRgba
cairo_status_t getColorStopRgba(int index, double offset, double red, double green, double blue, double alpha)

Gets the color and offset information at the given index for a gradient pattern. Values of index are 0 to 1 less than the number returned by Pattern.getColorStopCount. Since 1.4

createRgb
Pattern createRgb(double red, double green, double blue)

Creates a new cairo_pattern_t corresponding to an opaque color. The color components are floating point numbers in the range 0 to 1. If the values passed in are outside that range, they will be clamped. Since 1.0

createRgba
Pattern createRgba(double red, double green, double blue, double alpha)

Creates a new cairo_pattern_t corresponding to a translucent color. The color components are floating point numbers in the range 0 to 1. If the values passed in are outside that range, they will be clamped. Since 1.0

getRgba
cairo_status_t getRgba(double red, double green, double blue, double alpha)

Gets the solid color for a solid color pattern. Since 1.4

createForSurface
Pattern createForSurface(Surface surface)

Create a new cairo_pattern_t for the given surface. Since 1.0

getSurface
cairo_status_t getSurface(Surface surface)

Gets the surface of a surface pattern. The reference returned in surface is owned by the pattern; the caller should call Surface.reference if the surface is to be retained. Since 1.4

createLinear
Pattern createLinear(double x0, double y0, double x1, double y1)

Create 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 Pattern.addColorStopRgb or Pattern.addColorStopRgba. 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 Pattern.setMatrix. Since 1.0

getLinearPoints
cairo_status_t getLinearPoints(double x0, double y0, double x1, double y1)

Gets the gradient endpoints for a linear gradient. Since 1.4

createRadial
Pattern createRadial(double cx0, double cy0, double radius0, double cx1, double cy1, double radius1)

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 Pattern.addColorStopRgb or Pattern.addColorStopRgba. 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 Pattern.setMatrix. Since 1.0

getRadialCircles
cairo_status_t getRadialCircles(double x0, double y0, double r0, double x1, double y1, double r1)

Gets the gradient endpoint circles for a radial gradient, each specified as a center coordinate and a radius. Since 1.4

reference
Pattern reference()

Increases the reference count on pattern by one. This prevents pattern from being destroyed until a matching call to Pattern.destroy is made. The number of references to a cairo_pattern_t can be get using Pattern.getReferenceCount. Since 1.0

destroy
void destroy()

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

status
cairo_status_t status()

Checks whether an error has previously occurred for this pattern. Since 1.0

setExtend
void setExtend(cairo_extend_t extend)

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_NONE for surface patterns and CAIRO_EXTEND_PAD for gradient patterns. Since 1.0

getExtend
cairo_extend_t getExtend()

Gets the current extend mode for a pattern. See cairo_extend_t for details on the semantics of each extend strategy. Since 1.0

setFilter
void setFilter(cairo_filter_t filter)

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 Since 1.0

getFilter
cairo_filter_t getFilter()

Gets the current filter for a pattern. See cairo_filter_t for details on each filter. Since 1.0

setMatrix
void setMatrix(Matrix matrix)

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 Since 1.0

getMatrix
void getMatrix(Matrix matrix)

Stores the pattern's transformation matrix into matrix. Since 1.0

getType
cairo_pattern_type_t getType()

This function returns the type a pattern. See cairo_pattern_type_t for available types. Since 1.2

getReferenceCount
uint getReferenceCount()

Returns the current reference count of pattern. Since 1.4

setUserData
cairo_status_t setUserData(cairo_user_data_key_t* key, void* userData, cairo_destroy_func_t destroy)

Attach user data to pattern. To remove user data from a surface, call this function with the key that was used to set it and NULL for data. Since 1.4

getUserData
void* getUserData(cairo_user_data_key_t* key)

Return user data previously attached to pattern using the specified key. If no user data has been attached with the given key this function returns NULL. Since 1.4