cairomm  1.16.2
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Cairo::Pattern Class Reference

Cairo::Pattern is the paint with which cairo draws. More...

#include <cairomm/pattern.h>

Inheritance diagram for Cairo::Pattern:
Inheritance graph
[legend]

Public Types

enum class  Type {
  SOLID = CAIRO_PATTERN_TYPE_SOLID ,
  SURFACE = CAIRO_PATTERN_TYPE_SURFACE ,
  LINEAR = CAIRO_PATTERN_TYPE_LINEAR ,
  RADIAL = CAIRO_PATTERN_TYPE_RADIAL
}
 Type is used to describe the type of a given pattern. More...
 
enum class  Extend {
  NONE = CAIRO_EXTEND_NONE ,
  REPEAT = CAIRO_EXTEND_REPEAT ,
  REFLECT = CAIRO_EXTEND_REFLECT ,
  PAD = CAIRO_EXTEND_PAD
}
 Cairo::Extend is used to describe how pattern color/alpha will be determined for areas "outside" the pattern's natural area, (for example, outside the surface bounds or outside the gradient geometry). More...
 
typedef cairo_pattern_t cobject
 

Public Member Functions

 Pattern (cairo_pattern_t *cobject, bool has_reference=false)
 Create a C++ wrapper for the C instance. More...
 
 Pattern (const Pattern &)=delete
 
Patternoperator= (const Pattern &)=delete
 
virtual ~Pattern ()
 
void set_matrix (const Matrix & matrix)
 Sets the pattern's transformation matrix to @matrix. More...
 
void get_matrix (Matrix & matrix) const
 Returns the pattern's transformation matrix. More...
 
Matrix get_matrix () const
 Returns the pattern's transformation matrix. More...
 
Type get_type () const
 Returns the type of the pattern. More...
 
void set_extend (Extend extend)
 Sets the mode to be used for drawing outside the area of a pattern. More...
 
Extend get_extend () const
 Gets the current extend mode See Cairo::Extend for details on the semantics of each extend strategy. More...
 
cobjectcobj ()
 
const cobjectcobj () const
 
void reference () const
 
void unreference () const
 

Protected Member Functions

 Pattern ()
 

Protected Attributes

cobjectm_cobject
 

Detailed Description

Cairo::Pattern 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.

This is a reference-counted object that should be used via Cairo::RefPtr.

Member Typedef Documentation

◆ cobject

typedef cairo_pattern_t Cairo::Pattern::cobject

Member Enumeration Documentation

◆ Extend

Cairo::Extend is used to describe how pattern color/alpha will be determined for areas "outside" the pattern's natural area, (for example, outside the surface bounds or outside the gradient geometry).

Mesh patterns are not affected by the extend mode.

The default extend mode is Cairo::Pattern::Extend::NONE for surface patterns and Cairo::Pattern::Extend::PAD for gradient patterns.

New entries may be added in future versions.

Enumerator
NONE 

Pixels outside of the source pattern are fully transparent.

REPEAT 

The pattern is tiled by repeating.

REFLECT 

The pattern is tiled by reflecting at the edges (Implemented for surface patterns since 1.6)

PAD 

Pixels outside of the pattern copy the closest pixel from the source (Since 1.2; but only implemented for surface patterns since 1.6)

◆ Type

enum Cairo::Pattern::Type
strong

Type is used to describe the type of a given pattern.

The pattern type can be queried with Pattern::get_type().

New entries may be added in future versions.

Since
1.2
Enumerator
SOLID 

The pattern is a solid (uniform) color.

It may be opaque or translucent.

SURFACE 

The pattern is a based on a surface (an image)

LINEAR 

The pattern is a linear gradient.

RADIAL 

The pattern is a radial gradient.

Constructor & Destructor Documentation

◆ Pattern() [1/3]

Cairo::Pattern::Pattern ( cairo_pattern_t *  cobject,
bool  has_reference = false 
)
explicit

Create a C++ wrapper for the C instance.

This C++ instance should then be given to a RefPtr.

Parameters
cobjectThe C instance.
has_referenceWhether we already have a reference. Otherwise, the constructor will take an extra reference.

◆ Pattern() [2/3]

Cairo::Pattern::Pattern ( const Pattern )
delete

◆ ~Pattern()

virtual Cairo::Pattern::~Pattern ( )
virtual

◆ Pattern() [3/3]

Cairo::Pattern::Pattern ( )
protected

Member Function Documentation

◆ cobj() [1/2]

cobject* Cairo::Pattern::cobj ( )
inline

◆ cobj() [2/2]

const cobject* Cairo::Pattern::cobj ( ) const
inline

◆ get_extend()

Extend Cairo::Pattern::get_extend ( ) const

Gets the current extend mode See Cairo::Extend for details on the semantics of each extend strategy.

Since
1.12

◆ get_matrix() [1/2]

Matrix Cairo::Pattern::get_matrix ( ) const

Returns the pattern's transformation matrix.

Since
1.8

◆ get_matrix() [2/2]

void Cairo::Pattern::get_matrix ( Matrix matrix) const

Returns the pattern's transformation matrix.

◆ get_type()

Type Cairo::Pattern::get_type ( ) const

Returns the type of the pattern.

Since
1.2

◆ operator=()

Pattern& Cairo::Pattern::operator= ( const Pattern )
delete

◆ reference()

void Cairo::Pattern::reference ( ) const

◆ set_extend()

void Cairo::Pattern::set_extend ( Extend  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::Pattern::Extend::NONE for surface patterns and Cairo::Pattern::Extend::PAD for gradient patterns.

Parameters
Cairo::Extenddescribing how the area outsize of the pattern will be drawn
Since
1.12

◆ set_matrix()

void Cairo::Pattern::set_matrix ( const 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 it does by default the correct code to use is:

pattern->set_matrix(scaling_matrix(0.5, 0.5));

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 set_source().

◆ unreference()

void Cairo::Pattern::unreference ( ) const

Member Data Documentation

◆ m_cobject

cobject* Cairo::Pattern::m_cobject
protected

The documentation for this class was generated from the following file: