Patterns are 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 PatternType constructors listed below, or implicitly through Context.set_source_<type>() methods.
Pattern is the abstract base class from which all the other pattern classes derive. It cannot be instantiated directly.
Returns:  the current extend strategy used for drawing the Pattern. 

Return type:  int 
Gets the current extend mode for the Pattern. See EXTEND attributes for details on the semantics of each extend strategy.
Parameters:  extend – an EXTEND describing how the area outside of the Pattern will be drawn 

Sets the mode to be used for drawing outside the area of a Pattern.
The default extend mode is cairo.EXTEND_NONE for SurfacePattern and cairo.EXTEND_PAD for Gradient Patterns.
Parameters:  matrix – a 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:
matrix = cairo.Matrix(xx=0.5,yy=0.5)
pattern.set_matrix(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 userspace locking semantics of Context.set_source.
Parameters: 


Returns:  a new SolidPattern 
Raises :  MemoryError in case of no memory 
Creates a new SolidPattern 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.
Returns:  (red, green, blue, alpha) a tuple of float 

Gets the solid color for a SolidPattern.
New in version 1.4.
Parameters:  surface – a cairo Surface 

Returns:  a newly created SurfacePattern for the given surface. 
Raises :  MemoryError in case of no memory. 
Parameters:  filter – a FILTER describing the filter to use for resizing the Pattern 

Note that you might want to control filtering even when you do not have an explicit Pattern object, (for example when using Context.set_source_surface()). In these cases, it is convenient to use Context.get_source() to get access to the pattern that cairo creates implicitly. For example:
context.set_source_surface(image, x, y)
surfacepattern.set_filter(context.get_source(), cairo.FILTER_NEAREST)
Gradient is an abstract base class from which other Pattern classes derive. It cannot be instantiated directly.
Parameters: 


Adds an opaque color stop to a Gradient pattern. The offset specifies the location along the gradient’s control vector. For example, a LinearGradient’s control vector is from (x0,y0) to (x1,y1) while a RadialGradient’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 Context.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: 


Adds an opaque color stop to a Gradient pattern. The offset specifies the location along the gradient’s control vector. For example, a LinearGradient’s control vector is from (x0,y0) to (x1,y1) while a RadialGradient’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 Context.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: 


Returns:  a new LinearGradient 
Raises :  MemoryError in case of no memory 
Create a new LinearGradient along the line defined by (x0, y0) and (x1, y1). Before using the Gradient pattern, a number of color stops should be defined using Gradient.add_color_stop_rgb() or Gradient.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 Pattern.set_matrix()
Returns:  (x0, y0, x1, y1)  a tuple of float


Gets the gradient endpoints for a LinearGradient.
New in version 1.4.
Parameters: 


Returns:  the newly created RadialGradient 
Raises :  MemoryError in case of no memory 
Creates a new RadialGradient 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 Gradient.add_color_stop_rgb() or Gradient.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 Pattern.set_matrix().
Returns:  (x0, y0, r0, x1, y1, r1)  a tuple of float


Gets the Gradient endpoint circles for a RadialGradient, each specified as a center coordinate and a radius.
New in version 1.4.