Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::canvas::AffineTransform Class Reference

#include <affine_transform.hpp>

Public Member Functions

constexpr AffineTransform ()=default
constexpr AffineTransform (float a_, float b_, float c_, float d_, float e_, float f_)
constexpr AffineTransform followed_by (const AffineTransform &next) const
 Return the transform that applies *this FIRST, then next.
constexpr AffineTransform operator* (const AffineTransform &rhs) const
 Standard matrix product: (m1 * m2) applies m2 first, then m1.
constexpr AffineTransform translated (float tx, float ty) const
constexpr AffineTransform scaled (float sx, float sy) const
AffineTransform rotated (float radians) const
AffineTransform rotated (float radians, float px, float py) const
constexpr AffineTransform sheared (float shx, float shy) const
constexpr float determinant () const
bool is_singular () const
 True when the transform collapses area to zero and therefore cannot be inverted (e.g.
std::optional< AffineTransform > inverted () const
 The inverse, or nullopt when singular.
constexpr Point2D transform_point (Point2D p) const
constexpr void transform_point (float &x, float &y) const
Rect2D transform_rect (const Rect2D &r) const
 Axis-aligned bounding box of the four transformed corners.
constexpr bool is_identity () const
constexpr bool operator== (const AffineTransform &o) const
constexpr bool operator!= (const AffineTransform &o) const

Static Public Member Functions

static constexpr AffineTransform identity ()
static constexpr AffineTransform translation (float tx, float ty)
static constexpr AffineTransform scaling (float sx, float sy)
static constexpr AffineTransform scaling (float sx, float sy, float px, float py)
 Scale about the pivot (px, py) — the pivot is a fixed point.
static AffineTransform rotation (float radians)
static AffineTransform rotation (float radians, float px, float py)
 Rotate about the pivot (px, py) — the pivot is a fixed point.
static constexpr AffineTransform shear (float shx, float shy)
 Shear. shx slants x by y; shy slants y by x.

Public Attributes

float a = 1.0f
float b = 0.0f
float c = 0.0f
float d = 1.0f
float e = 0.0f
float f = 0.0f

Constructor & Destructor Documentation

◆ AffineTransform() [1/2]

pulp::canvas::AffineTransform::AffineTransform ( )
constexprdefault

◆ AffineTransform() [2/2]

pulp::canvas::AffineTransform::AffineTransform ( float a_,
float b_,
float c_,
float d_,
float e_,
float f_ )
inlineconstexpr

Member Function Documentation

◆ determinant()

float pulp::canvas::AffineTransform::determinant ( ) const
inlineconstexpr

◆ followed_by()

AffineTransform pulp::canvas::AffineTransform::followed_by ( const AffineTransform & next) const
inlineconstexpr

Return the transform that applies *this FIRST, then next.

Reads left-to-right in the order the caller thinks about it: scale(2).followed_by(translate(10, 0)) → scale, then translate.

◆ identity()

constexpr AffineTransform pulp::canvas::AffineTransform::identity ( )
inlinestaticconstexpr

◆ inverted()

std::optional< AffineTransform > pulp::canvas::AffineTransform::inverted ( ) const
inline

The inverse, or nullopt when singular.

Returning an optional (rather than silently handing back identity) forces callers to decide what a non-invertible transform means for them.

◆ is_identity()

bool pulp::canvas::AffineTransform::is_identity ( ) const
inlineconstexpr

◆ is_singular()

bool pulp::canvas::AffineTransform::is_singular ( ) const
inline

True when the transform collapses area to zero and therefore cannot be inverted (e.g.

scale(0, 1)).

◆ operator!=()

bool pulp::canvas::AffineTransform::operator!= ( const AffineTransform & o) const
inlineconstexpr

◆ operator*()

AffineTransform pulp::canvas::AffineTransform::operator* ( const AffineTransform & rhs) const
inlineconstexpr

Standard matrix product: (m1 * m2) applies m2 first, then m1.

(The mirror image of followed_by, for callers who think in matrices.)

◆ operator==()

bool pulp::canvas::AffineTransform::operator== ( const AffineTransform & o) const
inlineconstexpr

◆ rotated() [1/2]

AffineTransform pulp::canvas::AffineTransform::rotated ( float radians) const
inline

◆ rotated() [2/2]

AffineTransform pulp::canvas::AffineTransform::rotated ( float radians,
float px,
float py ) const
inline

◆ rotation() [1/2]

AffineTransform pulp::canvas::AffineTransform::rotation ( float radians)
inlinestatic

◆ rotation() [2/2]

AffineTransform pulp::canvas::AffineTransform::rotation ( float radians,
float px,
float py )
inlinestatic

Rotate about the pivot (px, py) — the pivot is a fixed point.

◆ scaled()

AffineTransform pulp::canvas::AffineTransform::scaled ( float sx,
float sy ) const
inlineconstexpr

◆ scaling() [1/2]

constexpr AffineTransform pulp::canvas::AffineTransform::scaling ( float sx,
float sy )
inlinestaticconstexpr

◆ scaling() [2/2]

constexpr AffineTransform pulp::canvas::AffineTransform::scaling ( float sx,
float sy,
float px,
float py )
inlinestaticconstexpr

Scale about the pivot (px, py) — the pivot is a fixed point.

◆ shear()

constexpr AffineTransform pulp::canvas::AffineTransform::shear ( float shx,
float shy )
inlinestaticconstexpr

Shear. shx slants x by y; shy slants y by x.

◆ sheared()

AffineTransform pulp::canvas::AffineTransform::sheared ( float shx,
float shy ) const
inlineconstexpr

◆ transform_point() [1/2]

void pulp::canvas::AffineTransform::transform_point ( float & x,
float & y ) const
inlineconstexpr

◆ transform_point() [2/2]

Point2D pulp::canvas::AffineTransform::transform_point ( Point2D p) const
inlineconstexpr

◆ transform_rect()

Rect2D pulp::canvas::AffineTransform::transform_rect ( const Rect2D & r) const
inline

Axis-aligned bounding box of the four transformed corners.

Under rotation or shear the result is the AABB of the rotated rect, which is larger than the source — that is the only meaningful answer for an axis-aligned rect type.

◆ translated()

AffineTransform pulp::canvas::AffineTransform::translated ( float tx,
float ty ) const
inlineconstexpr

◆ translation()

constexpr AffineTransform pulp::canvas::AffineTransform::translation ( float tx,
float ty )
inlinestaticconstexpr

Member Data Documentation

◆ a

float pulp::canvas::AffineTransform::a = 1.0f

◆ b

float pulp::canvas::AffineTransform::b = 0.0f

◆ c

float pulp::canvas::AffineTransform::c = 0.0f

◆ d

float pulp::canvas::AffineTransform::d = 1.0f

◆ e

float pulp::canvas::AffineTransform::e = 0.0f

◆ f

float pulp::canvas::AffineTransform::f = 0.0f

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