------------------------------ Pattern creation functions -- ------------------------------
procedure Add_Color_Stop_Rgb
(Pattern : Cairo_Pattern;
Offset : Gdouble;
Red : Gdouble;
Green : Gdouble;
Blue : Gdouble)
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.
a Cairo_Pattern
an Offset in the range [0.0 .. 1.0]
Red component of color
Green component of color
Blue component of color
procedure Add_Color_Stop_Rgba
(Pattern : Cairo_Pattern;
Offset : Gdouble;
Red : Gdouble;
Green : Gdouble;
Blue : Gdouble;
Alpha : Gdouble)
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.
a Cairo_Pattern
an Offset in the range [0.0 .. 1.0]
Red component of color
Green component of color
Blue component of color
Alpha component of color
type Cairo_Extend is
(Cairo_Extend_None,
Cairo_Extend_Repeat,
Cairo_Extend_Reflect,
Cairo_Extend_Pad
);
Pixels outside of the source pattern are fully transparent
The pattern is tiled by repeating
The pattern is tiled by reflecting at the edges (Implemented for surface patterns since 1.6)
type Cairo_Filter is
(Cairo_Filter_Fast,
Cairo_Filter_Good,
Cairo_Filter_Best,
Cairo_Filter_Nearest,
Cairo_Filter_Bilinear,
Cairo_Filter_Gaussian
);
A high-performance filter, with quality similar to Cairo_Filter_Nearest
A reasonable-performance filter, with quality similar to Cairo_Filter_Bilinear
The highest-quality available, performance may not be suitable for interactive use.
Nearest-neighbor filtering
Linear interpolation in two dimensions
type Cairo_Pattern_Type is
(Cairo_Pattern_Type_Solid,
Cairo_Pattern_Type_Surface,
Cairo_Pattern_Type_Linear,
Cairo_Pattern_Type_Radial
);
The pattern is a solid (uniform) color. It may be opaque or translucent.
The pattern is a based on a surface (an image).
The pattern is a linear gradient.
function Create_For_Surface
(Surface : Cairo_Surface)
return Cairo_Pattern
Create a new Cairo_Pattern for the given surface.
This function will always return a valid pointer, but if an error occurred the pattern status will be set to an error. To inspect the status of a pattern use Cairo.Pattern.Status.
the Surface
the newly created Cairo_Pattern if successful, or an error pattern in case of no memory. The caller owns the returned object and should call Cairo.Pattern.Destroy when finished with it.
function Create_Linear
(X0 : Gdouble;
Y0 : Gdouble;
X1 : Gdouble;
Y1 : Gdouble)
return Cairo_Pattern
Create a new linear gradient Cairo_Pattern 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.
This function will always return a valid pointer, but if an error occurred the pattern status will be set to an error. To inspect the status of a pattern use Cairo.Pattern.Status.
x coordinate of the start point
y coordinate of the start point
x coordinate of the end point
y coordinate of the end point
the newly created Cairo_Pattern if successful, or an error pattern in case of no memory. The caller owns the returned object and should call Cairo.Pattern.Destroy when finished with it.
function Create_Radial
(Cx0 : Gdouble;
Cy0 : Gdouble;
Radius0 : Gdouble;
Cx1 : Gdouble;
Cy1 : Gdouble;
Radius1 : Gdouble)
return Cairo_Pattern
Creates a new radial gradient Cairo_Pattern 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.
This function will always return a valid pointer, but if an error occurred the pattern status will be set to an error. To inspect the status of a pattern use Cairo.Pattern.Status.
X coordinate for the center of the start circle
Y coordinate for the center of the start circle
radius of the start circle
X coordinate for the center of the end circle
Y coordinate for the center of the end circle
radius of the end circle
the newly created Cairo_Pattern if successful, or an error pattern in case of no memory. The caller owns the returned object and should call Cairo.Pattern.Destroy when finished with it.
function Create_Rgb
(Red : Gdouble;
Green : Gdouble;
Blue : Gdouble)
return Cairo_Pattern
Creates a new Cairo_Pattern 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.
This function will always return a valid pointer, but if an error occurred the pattern status will be set to an error. To inspect the status of a pattern use Cairo.Pattern.Status.
Red component of the color
Green component of the color
Blue component of the color
the newly created Cairo_Pattern if successful, or an error pattern in case of no memory. The caller owns the returned object and should call Cairo.Pattern.Destroy when finished with it.
function Create_Rgba
(Red : Gdouble;
Green : Gdouble;
Blue : Gdouble;
Alpha : Gdouble)
return Cairo_Pattern
Creates a new Cairo_Pattern corresponding to a translucent color. The color components are floating point numbers in the range 0 to
If the values passed in are outside that range, they will be
clamped.
This function will always return a valid pointer, but if an error occurred the pattern status will be set to an error. To inspect the status of a pattern use Cairo.Pattern.Status.
Red component of the color
Green component of the color
Blue component of the color
Alpha component of the color
the newly created Cairo_Pattern if successful, or an error pattern in case of no memory. The caller owns the returned object and should call Cairo.Pattern.Destroy when finished with it.
procedure Destroy (Pattern : Cairo_Pattern)
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.
a Cairo_Pattern
function Get_Color_Stop_Count
(Pattern : Cairo_Pattern;
Count : access Gint)
return Cairo_Status
Gets the number of color stops specified in the given gradient pattern.
@since 1.4
a Cairo_Pattern
return value for the number of color stops, or NULL
Cairo_Status_Success, or Cairo_Status_Pattern_Type_Mismatch if pattern is not a gradient pattern.
function Get_Color_Stop_Rgba
(Pattern : Cairo_Pattern;
Index : Gint;
Offset : access Gdouble;
Red : access Gdouble;
Green : access Gdouble;
Blue : access Gdouble;
Alpha : access Gdouble)
return Cairo_Status
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 Cairo.Pattern.Get_Color_Stop_Count.
@since 1.4
a Cairo_Pattern
Index of the stop to return data for
return value for the Offset of the stop, or null
return value for Red component of color, or null
return value for Green component of color, or null
return value for Blue component of color, or null
return value for Alpha component of color, or null
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.
function Get_Extend (Pattern : Cairo_Pattern) return Cairo_Extend
Gets the current extend mode for a pattern. See Cairo_Extend for details on the semantics of each extend strategy.
a Cairo_Pattern
the current extend strategy used for drawing the pattern.
function Get_Filter (Pattern : Cairo_Pattern) return Cairo_Filter
Gets the current filter for a pattern. See Cairo_Filter for details on each filter.
a Cairo_Pattern
the current filter used for resizing the pattern.
function Get_Linear_Points
(Pattern : Cairo_Pattern;
X0 : access Gdouble;
Y0 : access Gdouble;
X1 : access Gdouble;
Y1 : access Gdouble)
return Cairo_Status
Gets the gradient endpoints for a linear gradient.
@since 1.4
a Cairo_Pattern
return value for the x coordinate of the first point, or null
return value for the y coordinate of the first point, or null
return value for the x coordinate of the second point, or null
return value for the y coordinate of the second point, or null
Cairo_Status_Success, or Cairo_Status_Pattern_Type_Mismatch if pattern is not a linear gradient pattern.
procedure Get_Matrix
(Pattern : Cairo_Pattern;
Matrix : access Cairo_Matrix)
Stores the pattern's transformation matrix into matrix.
a Cairo_Pattern
return value for the Matrix
function Get_Radial_Circles
(Pattern : Cairo_Pattern;
X0 : access Gdouble;
Y0 : access Gdouble;
R0 : access Gdouble;
X1 : access Gdouble;
Y1 : access Gdouble;
R1 : access Gdouble)
return Cairo_Status
Gets the gradient endpoint circles for a radial gradient, each specified as a center coordinate and a radius.
@since 1.4
a Cairo_Pattern
return value for the x coordinate of the center of the first circle, or null
return value for the y coordinate of the center of the first circle, or null
return value for the radius of the first circle, or null
return value for the x coordinate of the center of the second circle, or null
return value for the y coordinate of the center of the second circle, or null
return value for the radius of the second circle, or null
Cairo_Status_Success, or Cairo_Status_Pattern_Type_Mismatch if pattern is not a radial gradient pattern.
function Get_Reference_Count (Pattern : Cairo_Pattern) return Guint
Returns the current reference count of pattern.
@since 1.4
a Cairo_Pattern
the current reference count of pattern. If the object is a nil object, 0 will be returned.
function Get_Rgba
(Pattern : Cairo_Pattern;
Red : access Gdouble;
Green : access Gdouble;
Blue : access Gdouble;
Alpha : access Gdouble)
return Cairo_Status
Gets the solid color for a solid color pattern.
@since 1.4
a Cairo_Pattern
return value for Red component of color, or null
return value for Green component of color, or null
return value for Blue component of color, or null
return value for Alpha component of color, or null
Cairo_Status_Success, or Cairo_Status_Pattern_Type_Mismatch if the pattern is not a solid color pattern.
function Get_Surface
(Pattern : Cairo_Pattern;
Surface : Cairo_Surface)
return Cairo_Status
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.
@since 1.4
a Cairo_Pattern
return value for Surface of pattern, or null
Cairo_Status_Success, or Cairo_Status_Pattern_Type_Mismatch if the pattern is not a surface pattern.
function Get_Type (Pattern : Cairo_Pattern) return Cairo_Pattern_Type
This function returns the type a pattern. See Cairo_Pattern_Type for available types.
@since 1.2
a Cairo_Pattern
The type of pattern.
function Get_User_Data
(Pattern : Cairo_Pattern;
Key : access Cairo_User_Data_Key) return System.Address
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 System.Null_Address.
@since 1.4
a Cairo_Pattern
the address of the Cairo_User_Data_Key the user data was attached to
the user data previously attached or System.Null_Address.
function Reference (Pattern : Cairo_Pattern) return Cairo_Pattern
Increases the reference count on pattern by one. This prevents pattern from being destroyed until a matching call to Cairo.Pattern.Destroy is made.
The number of references to a Cairo_Pattern can be get using Cairo.Pattern.Get_Reference_Count.
a Cairo_Pattern
the referenced Cairo_Pattern.
procedure Set_Extend (Pattern : Cairo_Pattern; Extend : Cairo_Extend)
Sets the mode to be used for drawing outside the area of a pattern. See Cairo_Extend 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.
a Cairo_Pattern
a Cairo_Extend describing how the area outside of the pattern will be drawn
procedure Set_Filter (Pattern : Cairo_Pattern; Filter : Cairo_Filter)
Sets the filter to be used for resizing when using this pattern. See Cairo_Filter for details on each filter.
Note that you might want to control filtering even when you do not have an explicit Cairo_Pattern 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_Nearest);
a Cairo_Pattern
a Cairo_Filter describing the Filter to use for resizing the pattern
procedure Set_Matrix
(Pattern : Cairo_Pattern;
Matrix : access Cairo_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 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.
a Cairo_Pattern
a Cairo_Matrix
function Set_User_Data
(Pattern : Cairo_Pattern;
Key : access Cairo_User_Data_Key;
User_Data : System.Address;
Destroy : Cairo_Destroy_Func) return Cairo_Status
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_Address for data.
@since 1.4
a Cairo_Pattern
the address of a Cairo_User_Data_Key to attach the user data to
the user data to attach to the Cairo_Pattern
a Cairo_Destroy_Func which will be called when the Cairo_Context is destroyed or when new user data is attached using the same key.
Cairo_Status_Success or Cairo_Status_No_Memory if a slot could not be allocated for the user data.
function Status (Pattern : Cairo_Pattern) return Cairo_Status
Checks whether an error has previously occurred for this pattern.
a Cairo_Pattern
Cairo_Status_Success, Cairo_Status_No_Memory, or Cairo_Status_Pattern_Type_Mismatch.