Module: graphics.transform

Source: ./graphics/transform.reef


Overview

graphics/transform.reef - 2D affine transformations Part of reef-stdlib graphics module


Types

Transform

Fields:

Name Type
a float
b float
c float
d float
e float
f float

Functions

fn identity(): Transform

Identity transform (no change)

fn translate(tx: float, ty: float): Transform

Translation transform

fn scale(s: float): Transform

Uniform scale transform

fn scale_xy(sx: float, sy: float): Transform

Non-uniform scale transform

fn rotate(angle: float): Transform

Rotation transform (angle in radians, counter-clockwise)

fn skew_x(angle: float): Transform

Skew X transform (angle in radians)

fn skew_y(angle: float): Transform

Skew Y transform (angle in radians)

fn from_matrix(a: float, b: float, c: float, d: float, e: float, f: float): Transform

Construct from explicit matrix values

fn multiply(t1: Transform, t2: Transform): Transform

Multiply two transforms: result = t1 * t2 Applies t2 first, then t1 (standard matrix multiplication order)

fn determinant(t: Transform): float

Calculate determinant

fn is_invertible(t: Transform): bool

Check if transform is invertible

fn invert(t: Transform): Transform

Invert transform (returns identity if not invertible)

fn apply_point(t: Transform, p: core.Point): core.Point

Apply transform to a point

fn apply_vector(t: Transform, dx: float, dy: float): core.Point

Apply transform to a vector (ignores translation)

fn get_translation(t: Transform): core.Point

Get translation component

fn get_scale(t: Transform): core.Point

Get scale component (approximate for non-axis-aligned scales)

fn get_rotation(t: Transform): float

Get rotation angle (approximate, assumes uniform scale)

fn then_translate(t: Transform, tx: float, ty: float): Transform

Chain translation after current transform

fn then_scale(t: Transform, s: float): Transform

Chain uniform scale after current transform

fn then_scale_xy(t: Transform, sx: float, sy: float): Transform

Chain non-uniform scale after current transform

fn then_rotate(t: Transform, angle: float): Transform

Chain rotation after current transform

fn then_skew_x(t: Transform, angle: float): Transform

Chain skew X after current transform

fn then_skew_y(t: Transform, angle: float): Transform

Chain skew Y after current transform

fn is_identity(t: Transform): bool

Check if transform is identity


Generated by reefc doc