public class Matrix(
public val values: FloatArray =
floatArrayOf(1f, 0f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, 0f, 1f)
)
Functions
get
public inline operator fun get(row: Int, column: Int): Float
set
public inline operator fun set(row: Int, column: Int, v: Float)
map
public fun map(point: Offset): Offset
Does the 3D transform on point and returns the x and y values in an Offset.
map
public fun map(rect: Rect): Rect
Does a 3D transform on rect and returns its bounds after the transform.
map
public fun map(rect: MutableRect)
Does a 3D transform on rect, transforming rect with the results.
timesAssign
public operator fun timesAssign(m: Matrix)
Multiply this matrix by m and assign the result to this matrix.
toString
override fun toString(): String
invert
public fun invert()
Invert this Matrix.
reset
public fun reset()
Resets the this to the identity matrix.
setFrom
public fun setFrom(matrix: Matrix)
Sets the entire matrix to the matrix in matrix.
rotateX
public fun rotateX(degrees: Float)
Applies a degrees rotation around X to this.
rotateY
public fun rotateY(degrees: Float)
Applies a degrees rotation around Y to this.
rotateZ
public fun rotateZ(degrees: Float)
Applies a degrees rotation around Z to this.
scale
public fun scale(x: Float = 1f, y: Float = 1f, z: Float = 1f)
Scale this matrix by x, y, z
translate
public fun translate(x: Float = 0f, y: Float = 0f, z: Float = 0f)
Translate this matrix by x, y, z
resetToPivotedTransform
public fun resetToPivotedTransform(
pivotX: Float = 0f,
pivotY: Float = 0f,
translationX: Float = 0f,
translationY: Float = 0f,
translationZ: Float = 0f,
rotationX: Float = 0f,
rotationY: Float = 0f,
rotationZ: Float = 0f,
scaleX: Float = 1f,
scaleY: Float = 1f,
scaleZ: Float = 1f,
)
Resets this matrix to a "TRS" (translation, rotation, scale) transform around a pivot point. The transform operations encoded in the matrix are the following, in this specific order:
- A translation by -
pivotX, -pivotY - A translation by
translationX,translationY, andtranslationZ - An X rotation by
rotationX - A Y rotation by
rotationY - A Z rotation by
rotationZ - A scale by
scaleXandscaleY - A translation by
pivotX,pivotY
Calling this method is equivalent to the following code:
val m: Matrix ...
m.reset()
m.translate(-pivotX, -pivotY)
m *= Matrix().apply {
translate(translationX, translationY)
rotateX(rotationX)
rotateY(rotationY)
rotateZ(rotationZ)
scale(scaleX, scaleY)
}
m *= Matrix().apply { translate(pivotX, pivotY) }
Members
Companion
public companion object
Properties
ScaleX
public const val ScaleX: Int = 0
Index of the flattened array that represents the scale factor along the X axis
SkewY
public const val SkewY: Int = 1
Index of the flattened array that represents the skew factor along the Y axis
Perspective0
public const val Perspective0: Int = 3
Index of the flattened array that represents the perspective factor along the X axis
SkewX
public const val SkewX: Int = 4
Index of the flattened array that represents the skew factor along the X axis
ScaleY
public const val ScaleY: Int = 5
Index of the flattened array that represents the scale factor along the Y axis
Perspective1
public const val Perspective1: Int = 7
Index of the flattened array that represents the perspective factor along the Y axis
ScaleZ
public const val ScaleZ: Int = 10
Index of the flattened array that represents the scale factor along the Z axis
TranslateX
public const val TranslateX: Int = 12
Index of the flattened array that represents the translation along the X axis
TranslateY
public const val TranslateY: Int = 13
Index of the flattened array that represents the translation along the Y axis
TranslateZ
public const val TranslateZ: Int = 14
Index of the flattened array that represents the translation along the Z axis
Perspective2
public const val Perspective2: Int = 15
Index of the flattened array that represents the perspective factor along the Z axis