NovaSVG 0.10.0
A header-only SVG library
Loading...
Searching...
No Matches
novasvg::Matrix Class Reference

Represents a 2D transformation matrix. More...

#include <novasvg.h>

Public Member Functions

 Matrix ()=default
 Initializes the matrix to the identity matrix.
 
 Matrix (float a, float b, float c, float d, float e, float f)
 Constructs a matrix with the specified values.
 
 Matrix (const matrix_t &matrix)
 
 Matrix (const Transform &transform)
 
Matrix operator* (const Matrix &matrix) const
 Multiplies this matrix with another matrix.
 
Matrix & operator*= (const Matrix &matrix)
 Multiplies this matrix with another matrix in place.
 
Matrix & multiply (const Matrix &matrix)
 Multiplies this matrix with another matrix.
 
Matrix & translate (float tx, float ty)
 Translates this matrix by the specified offsets.
 
Matrix & scale (float sx, float sy)
 Scales this matrix by the specified factors.
 
Matrix & rotate (float angle, float cx=0.f, float cy=0.f)
 Rotates this matrix by the specified angle around a point.
 
Matrix & shear (float shx, float shy)
 Shears this matrix by the specified factors.
 
Matrix & invert ()
 Inverts this matrix.
 
Matrix inverse () const
 Returns the inverse of this matrix.
 
void reset ()
 Resets this matrix to the identity matrix.
 

Static Public Member Functions

static Matrix translated (float tx, float ty)
 Creates a translation matrix with the specified offsets.
 
static Matrix scaled (float sx, float sy)
 Creates a scaling matrix with the specified factors.
 
static Matrix rotated (float angle, float cx=0.f, float cy=0.f)
 Creates a rotation matrix with the specified angle around a point.
 
static Matrix sheared (float shx, float shy)
 Creates a shearing matrix with the specified factors.
 

Public Attributes

float a {1}
 The horizontal scaling factor.
 
float b {0}
 The vertical shearing factor.
 
float c {0}
 The horizontal shearing factor.
 
float d {1}
 The vertical scaling factor.
 
float e {0}
 The horizontal translation offset.
 
float f {0}
 The vertical translation offset.
 

Detailed Description

Represents a 2D transformation matrix.

Definition at line 216 of file novasvg.h.

Constructor & Destructor Documentation

◆ Matrix() [1/4]

novasvg::Matrix::Matrix ( )
default

Initializes the matrix to the identity matrix.

References novasvg::operator*().

Referenced by reset().

◆ Matrix() [2/4]

novasvg::Matrix::Matrix ( float  a,
float  b,
float  c,
float  d,
float  e,
float  f 
)
inline

Constructs a matrix with the specified values.

Parameters
aThe horizontal scaling factor.
bThe vertical shearing factor.
cThe horizontal shearing factor.
dThe vertical scaling factor.
eThe horizontal translation offset.
fThe vertical translation offset.

Definition at line 748 of file novasvg.h.

◆ Matrix() [3/4]

novasvg::Matrix::Matrix ( const matrix_t &  matrix)
inline

Definition at line 753 of file novasvg.h.

◆ Matrix() [4/4]

novasvg::Matrix::Matrix ( const Transform &  transform)
inline

Definition at line 758 of file novasvg.h.

Member Function Documentation

◆ inverse()

Matrix novasvg::Matrix::inverse ( ) const
inline

Returns the inverse of this matrix.

Returns
A new matrix that is the inverse of this matrix.

Definition at line 803 of file novasvg.h.

References novasvg::Transform::inverse().

Referenced by invert().

◆ invert()

Matrix & novasvg::Matrix::invert ( )
inline

Inverts this matrix.

Returns
A reference to this matrix after inversion.

Definition at line 808 of file novasvg.h.

References inverse().

◆ multiply()

Matrix & novasvg::Matrix::multiply ( const Matrix &  matrix)
inline

Multiplies this matrix with another matrix.

Parameters
matrixThe matrix to multiply with.
Returns
A reference to this matrix after multiplication.

Definition at line 778 of file novasvg.h.

Referenced by rotate(), scale(), shear(), and translate().

◆ operator*()

Matrix novasvg::Matrix::operator* ( const Matrix &  matrix) const
inline

Multiplies this matrix with another matrix.

Parameters
matrixThe matrix to multiply with.
Returns
A new matrix that is the result of the multiplication.

Definition at line 763 of file novasvg.h.

◆ operator*=()

Matrix & novasvg::Matrix::operator*= ( const Matrix &  matrix)
inline

Multiplies this matrix with another matrix in place.

Parameters
matrixThe matrix to multiply with.
Returns
A reference to this matrix after multiplication.

Definition at line 773 of file novasvg.h.

◆ reset()

void novasvg::Matrix::reset ( )
inline

Resets this matrix to the identity matrix.

Definition at line 813 of file novasvg.h.

References Matrix().

◆ rotate()

Matrix & novasvg::Matrix::rotate ( float  angle,
float  cx = 0.f,
float  cy = 0.f 
)
inline

Rotates this matrix by the specified angle around a point.

Parameters
angleThe rotation angle in degrees.
cxThe x-coordinate of the center of rotation.
cyThe y-coordinate of the center of rotation.
Returns
A reference to this matrix after rotation.

Definition at line 793 of file novasvg.h.

References multiply(), and rotated().

◆ rotated()

Matrix novasvg::Matrix::rotated ( float  angle,
float  cx = 0.f,
float  cy = 0.f 
)
inlinestatic

Creates a rotation matrix with the specified angle around a point.

Parameters
angleThe rotation angle in degrees.
cxThe x-coordinate of the center of rotation.
cyThe y-coordinate of the center of rotation.
Returns
A new rotation matrix.

Definition at line 828 of file novasvg.h.

References novasvg::Transform::rotated().

Referenced by rotate().

◆ scale()

Matrix & novasvg::Matrix::scale ( float  sx,
float  sy 
)
inline

Scales this matrix by the specified factors.

Parameters
sxThe horizontal scaling factor.
syThe vertical scaling factor.
Returns
A reference to this matrix after scaling.

Definition at line 783 of file novasvg.h.

References multiply(), and scaled().

◆ scaled()

Matrix novasvg::Matrix::scaled ( float  sx,
float  sy 
)
inlinestatic

Creates a scaling matrix with the specified factors.

Parameters
sxThe horizontal scaling factor.
syThe vertical scaling factor.
Returns
A new scaling matrix.

Definition at line 823 of file novasvg.h.

References novasvg::Transform::scaled().

Referenced by scale().

◆ shear()

Matrix & novasvg::Matrix::shear ( float  shx,
float  shy 
)
inline

Shears this matrix by the specified factors.

Parameters
shxThe horizontal shearing factor.
shyThe vertical shearing factor.
Returns
A reference to this matrix after shearing.

Definition at line 798 of file novasvg.h.

References multiply(), and sheared().

◆ sheared()

Matrix novasvg::Matrix::sheared ( float  shx,
float  shy 
)
inlinestatic

Creates a shearing matrix with the specified factors.

Parameters
shxThe horizontal shearing factor.
shyThe vertical shearing factor.
Returns
A new shearing matrix.

Definition at line 833 of file novasvg.h.

References novasvg::Transform::sheared().

Referenced by shear().

◆ translate()

Matrix & novasvg::Matrix::translate ( float  tx,
float  ty 
)
inline

Translates this matrix by the specified offsets.

Parameters
txThe horizontal translation offset.
tyThe vertical translation offset.
Returns
A reference to this matrix after translation.

Definition at line 788 of file novasvg.h.

References multiply(), and translated().

◆ translated()

Matrix novasvg::Matrix::translated ( float  tx,
float  ty 
)
inlinestatic

Creates a translation matrix with the specified offsets.

Parameters
txThe horizontal translation offset.
tyThe vertical translation offset.
Returns
A new translation matrix.

Definition at line 818 of file novasvg.h.

References novasvg::Transform::translated().

Referenced by translate().

Member Data Documentation

◆ a

float novasvg::Matrix::a {1}

The horizontal scaling factor.

Definition at line 348 of file novasvg.h.

◆ b

float novasvg::Matrix::b {0}

The vertical shearing factor.

Definition at line 349 of file novasvg.h.

◆ c

float novasvg::Matrix::c {0}

The horizontal shearing factor.

Definition at line 350 of file novasvg.h.

◆ d

float novasvg::Matrix::d {1}

The vertical scaling factor.

Definition at line 351 of file novasvg.h.

◆ e

float novasvg::Matrix::e {0}

The horizontal translation offset.

Definition at line 352 of file novasvg.h.

◆ f

float novasvg::Matrix::f {0}

The vertical translation offset.

Definition at line 353 of file novasvg.h.


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