Matrix is a linear transform matrix in homogenous coordinates. PDF coordinate transforms are always affine so we only need 6 of these. See newMatrix.
type Matrix [9]float64
func IdentityMatrix() Matrix
IdentityMatrix returns the identity transform.
func NewMatrix(a, b, c, d, tx, ty float64) Matrix
NewMatrix returns an affine transform matrix laid out in homogenous coordinates as
a b 0 c d 0 tx ty 1
func NewMatrixFromTransforms(xScale, yScale, theta, tx, ty float64) Matrix
NewMatrix returns an affine transform matrix that
scales by `xScale`, `yScale`, rotated by `theta` degrees, and translates by `tx`, `ty`.
func RotationMatrix(angle float64) Matrix
RotationMatrix returns a matrix that rotates by angle `angle`, specified in radians.
func ScaleMatrix(x, y float64) Matrix
ScaleMatrix returns a matrix that scales by `x`,`y`.
func ShearMatrix(x, y float64) Matrix
ShearMatrix returns a matrix that shears `x`,`y`.
func TranslationMatrix(tx, ty float64) Matrix
TranslationMatrix returns a matrix that translates by `tx`,`ty`.
func (m Matrix) Angle() float64
Angle returns the angle of the affine transform in `m` in degrees.
func (m *Matrix) Clone() Matrix
Clone returns a copy of the current matrix.
func (m *Matrix) Concat(b Matrix)
Concat sets `m` to `b` × `m`. `b` needs to be created by newMatrix. i.e. It must be an affine transform.
b00 b01 0 m00 m01 0 b00*m00 + b01*m01 b00*m10 + b01*m11 0 b10 b11 0 × m10 m11 0 ➔ b10*m00 + b11*m01 b10*m10 + b11*m11 0 b20 b21 1 m20 m21 1 b20*m00 + b21*m10 + m20 b20*m01 + b21*m11 + m21 1
func (m Matrix) Identity() bool
Identity returns true if `m` is the identity matrix.
func (m Matrix) Inverse() (Matrix, bool)
Inverse returns the inverse of `m` and a boolean to indicate whether the inverse exists.
func (m Matrix) Mult(b Matrix) Matrix
Mult returns `b` × `m`.
func (m Matrix) Rotate(theta float64) Matrix
Rotate returns `m` with an extra rotation of `theta` degrees. NOTE: This rotation pre-multiplies `m` so it will be scaled and rotated by `m`.
func (m Matrix) Round(precision float64) Matrix
Round rounds off matrix to specified precision. E.g. m.Round(0.000001)
func (m Matrix) Scale(xScale, yScale float64) Matrix
Scale returns `m` with an extra scaling of `xScale`,`yScale` to `m`. NOTE: This scaling pre-multiplies `m` so it will be scaled and rotated by `m`.
func (m Matrix) ScalingFactorX() float64
ScalingFactorX returns the X scaling of the affine transform.
func (m Matrix) ScalingFactorY() float64
ScalingFactorY returns the Y scaling of the affine transform.
func (m *Matrix) Set(a, b, c, d, tx, ty float64)
Set sets `m` to affine transform a,b,c,d,tx,ty.
func (m *Matrix) Shear(x, y float64)
Shear shears the current matrix by `x',`y`.
func (m Matrix) Singular() bool
Singular returns true if `m` contains a singular matrix. NOTE(peterwilliams97). We are just checking for bad "cm" commands. We don't need to compute the condition number.
func (m Matrix) String() string
String returns a string describing `m`.
func (m Matrix) Transform(x, y float64) (float64, float64)
Transform returns coordinates `x`,`y` transformed by `m`.
func (m Matrix) Translate(tx, ty float64) Matrix
Translate returns `m` with an extra translation of `tx`,`ty`.
func (m Matrix) Translation() (float64, float64)
Translation returns the translation part of `m`.
func (m Matrix) Unrealistic() bool
Unrealistic returns true if `m` is too small to have been created intentionally. If it returns true then `m` probably contains junk values, due to some processing error in the PDF generator or our code.
Point defines a point (X,Y) in Cartesian coordinates.
type Point struct { X float64 Y float64 }
func NewPoint(x, y float64) Point
NewPoint returns a Point at `(x,y)`.
func (p Point) Displace(delta Point) Point
Displace returns a new Point at location `p` + `delta`.
func (a Point) Distance(b Point) float64
Distance returns the distance between `a` and `b`.
func (a Point) Interpolate(b Point, t float64) Point
Interpolate does linear interpolation between point `a` and `b` for value `t`.
func (p Point) Rotate(theta float64) Point
Rotate returns a new Point at `p` rotated by `theta` degrees.
func (p *Point) Set(x, y float64)
Set mutates `p` and sets to coordinates `(x, y)`.
func (p Point) String() string
String returns a string describing `p`.
func (p *Point) Transform(a, b, c, d, tx, ty float64)
Transform mutates and transforms `p` by the affine transformation a, b, c, d, tx, ty.