MCPcopy Create free account
hub / github.com/HumbleUI/Skija / Matrix33

Class Matrix33

shared/java/Matrix33.java:17–243  ·  view source on GitHub ↗

Matrix holds a 3x3 matrix for transforming coordinates. This allows mapping Point and vectors with translation, scaling, skewing, rotation, and perspective. Matrix includes a hidden variable that classifies the type of matrix to improve performance. Matrix is not thread safe unless getTyp

Source from the content-addressed store, hash-verified

15 * @see <a href="https://fiddle.skia.org/c/@Matrix_063">https://fiddle.skia.org/c/@Matrix_063</a>
16 */
17@Data
18public class Matrix33 {
19 /**
20 * <p>Matrix33 elements are in row-major order.</p>
21 *
22 * <pre><code>
23 * | scaleX skewX transX |
24 * | skewY scaleY transY |
25 * | persp0 persp1 persp2 |
26 * </code></pre>
27 */
28 @ApiStatus.Internal
29 public final float[] _mat;
30
31 public Matrix33(float... mat) {
32 assert mat.length == 9 : "Expected 9 elements, got " + mat == null ? null : mat.length;
33 _mat = mat;
34 }
35
36 /**
37 * An identity Matrix33:
38 *
39 * <pre><code>
40 * | 1 0 0 |
41 * | 0 1 0 |
42 * | 0 0 1 |
43 * </code></pre>
44 */
45 @NotNull
46 public static final Matrix33 IDENTITY = makeTranslate(0, 0);
47
48 /**
49 * <p>Creates a Matrix33 to translate by (dx, dy). Returned matrix is:</p>
50 *
51 * <pre><code>
52 * | 1 0 dx |
53 * | 0 1 dy |
54 * | 0 0 1 |
55 * </code></pre>
56 *
57 * @param dx horizontal translation
58 * @param dy vertical translation
59 * @return Matrix33 with translation
60 */
61 @NotNull @Contract("_, _ -> new")
62 public static Matrix33 makeTranslate(float dx, float dy) {
63 return new Matrix33(new float[] {1, 0, dx, 0, 1, dy, 0, 0, 1});
64 }
65
66 /**
67 * <p>Creates a Matrix33 to scale by s. Returned matrix is:</p>
68 *
69 * <pre><code>
70 * | s 0 0 |
71 * | 0 s 0 |
72 * | 0 0 1 |
73 * </code></pre>
74 *

Callers

nothing calls this directly

Calls 1

makeTranslateMethod · 0.95

Tested by

no test coverage detected