MatrixProtocol
public protocol MatrixProtocol
A PangoMatrix specifies a transformation between user-space
and device coordinates.
The transformation is given by
x_device = x_user * matrix->xx + y_user * matrix->xy + matrix->x0;
y_device = x_user * matrix->yx + y_user * matrix->yy + matrix->y0;
The MatrixProtocol protocol exposes the methods and properties of an underlying PangoMatrix instance.
The default implementation of these can be found in the protocol extension below.
For a concrete class that implements these methods and properties, see Matrix.
Alternatively, use MatrixRef as a lighweight, unowned reference if you already have an instance you just want to use.
-
Untyped pointer to the underlying
PangoMatrixinstance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get } -
matrix_ptrDefault implementationTyped pointer to the underlying
PangoMatrixinstance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
PangoMatrixinstance.Declaration
Swift
var matrix_ptr: UnsafeMutablePointer<PangoMatrix>! { get } -
Required Initialiser for types conforming to
MatrixProtocolDeclaration
Swift
init(raw: UnsafeMutableRawPointer)
-
concat(newMatrix:Extension method) Changes the transformation represented by
matrixto be the transformation given by first applying transformation given bynew_matrixthen applying the original transformation.Declaration
Swift
@inlinable func concat<MatrixT>(newMatrix: MatrixT) where MatrixT : MatrixProtocol -
copy()Extension methodCopies a
PangoMatrix.Declaration
Swift
@inlinable func copy() -> Pango.MatrixRef! -
free()Extension methodFree a
PangoMatrix.Declaration
Swift
@inlinable func free() -
getFontScaleFactor()Extension methodReturns the scale factor of a matrix on the height of the font.
That is, the scale factor in the direction perpendicular to the vector that the X coordinate is mapped to. If the scale in the X coordinate is needed as well, use [method
Pango.Matrix.get_font_scale_factors].Declaration
Swift
@inlinable func getFontScaleFactor() -> CDouble -
getFontScaleFactors(xscale:Extension methodyscale: ) Calculates the scale factor of a matrix on the width and height of the font.
That is,
xscaleis the scale factor in the direction of the X coordinate, andyscaleis the scale factor in the direction perpendicular to the vector that the X coordinate is mapped to.Note that output numbers will always be non-negative.
Declaration
Swift
@inlinable func getFontScaleFactors(xscale: UnsafeMutablePointer<CDouble>! = nil, yscale: UnsafeMutablePointer<CDouble>! = nil) -
getSlantRatio()Extension methodGets the slant ratio of a matrix.
For a simple shear matrix in the form:
1 λ 0 1this is simply λ.
Declaration
Swift
@inlinable func getSlantRatio() -> CDouble -
rotate(degrees:Extension method) Changes the transformation represented by
matrixto be the transformation given by first rotating bydegreesdegrees counter-clockwise then applying the original transformation.Declaration
Swift
@inlinable func rotate(degrees: CDouble) -
scale(scaleX:Extension methodscaleY: ) Changes the transformation represented by
matrixto be the transformation given by first scaling bysxin the X direction andsyin the Y direction then applying the original transformation.Declaration
Swift
@inlinable func scale(scaleX: CDouble, scaleY: CDouble) -
transformDistance(dx:Extension methoddy: ) Transforms the distance vector (
dx,dy) bymatrix.This is similar to [method
Pango.Matrix.transform_point], except that the translation components of the transformation are ignored. The calculation of the returned vector is as follows:dx2 = dx1 * xx + dy1 * xy; dy2 = dx1 * yx + dy1 * yy;Affine transformations are position invariant, so the same vector always transforms to the same vector. If (
x1,y1) transforms to (x2,y2) then (x1+dx1,y1+dy1) will transform to (x1+dx2,y1+dy2) for all values ofx1andx2.Declaration
Swift
@inlinable func transformDistance(dx: UnsafeMutablePointer<CDouble>!, dy: UnsafeMutablePointer<CDouble>!) -
transformPixelRectangle(rect:Extension method) First transforms the
rectusingmatrix, then calculates the bounding box of the transformed rectangle.This function is useful for example when you want to draw a rotated
PangoLayoutto an image buffer, and want to know how large the image should be and how much you should shift the layout when rendering.For better accuracy, you should use [method
Pango.Matrix.transform_rectangle] on original rectangle in Pango units and convert to pixels afterward using [funcextents_to_pixels]‘s first argument.Declaration
Swift
@inlinable func transformPixelRectangle<RectangleT>(rect: RectangleT) where RectangleT : RectangleProtocol -
transformPoint(x:Extension methody: ) Transforms the point (
x,y) bymatrix.Declaration
Swift
@inlinable func transformPoint(x: UnsafeMutablePointer<CDouble>!, y: UnsafeMutablePointer<CDouble>!) -
transformRectangle(rect:Extension method) First transforms
rectusingmatrix, then calculates the bounding box of the transformed rectangle.This function is useful for example when you want to draw a rotated
PangoLayoutto an image buffer, and want to know how large the image should be and how much you should shift the layout when rendering.If you have a rectangle in device units (pixels), use [method
Pango.Matrix.transform_pixel_rectangle].If you have the rectangle in Pango units and want to convert to transformed pixel bounding box, it is more accurate to transform it first (using this function) and pass the result to
pango_extents_to_pixels(), first argument, for an inclusive rounded rectangle. However, there are valid reasons that you may want to convert to pixels first and then transform, for example when the transformed coordinates may overflow in Pango units (large matrix translation for example).Declaration
Swift
@inlinable func transformRectangle<RectangleT>(rect: RectangleT) where RectangleT : RectangleProtocol -
translate(tx:Extension methodty: ) Changes the transformation represented by
matrixto be the transformation given by first translating by (tx,ty) then applying the original transformation.Declaration
Swift
@inlinable func translate(tx: CDouble, ty: CDouble) -
gravityGetForMatrix()Extension methodFinds the gravity that best matches the rotation component in a
PangoMatrix.Declaration
Swift
@inlinable func gravityGetForMatrix() -> PangoGravity -
fontScaleFactorExtension methodReturns the scale factor of a matrix on the height of the font.
That is, the scale factor in the direction perpendicular to the vector that the X coordinate is mapped to. If the scale in the X coordinate is needed as well, use [method
Pango.Matrix.get_font_scale_factors].Declaration
Swift
@inlinable var fontScaleFactor: CDouble { get } -
slantRatioExtension methodGets the slant ratio of a matrix.
For a simple shear matrix in the form:
1 λ 0 1this is simply λ.
Declaration
Swift
@inlinable var slantRatio: CDouble { get } -
xxExtension method1st component of the transformation matrix
Declaration
Swift
@inlinable var xx: CDouble { get set } -
xyExtension method2nd component of the transformation matrix
Declaration
Swift
@inlinable var xy: CDouble { get set } -
yxExtension method3rd component of the transformation matrix
Declaration
Swift
@inlinable var yx: CDouble { get set } -
yyExtension method4th component of the transformation matrix
Declaration
Swift
@inlinable var yy: CDouble { get set } -
x0Extension methodx translation
Declaration
Swift
@inlinable var x0: CDouble { get set } -
y0Extension methody translation
Declaration
Swift
@inlinable var y0: CDouble { get set }
View on GitHub
Install in Dash
MatrixProtocol Protocol Reference