@Properties(inherit=Skia.class) public class sk_matrix_t extends Pointer
(X,Y) = T[M]((x,y)) X = (M[0] * x + M[1] * y + M[2]) / (M[6] * x + M[7] * y + M[8]); Y = (M[3] * x + M[4] * y + M[5]) / (M[6] * x + M[7] * y + M[8]);
Therefore, the identity matrix is
sk_matrix_t identity = {{1, 0, 0, 0, 1, 0, 0, 0, 1}};
A matrix that scales by sx and sy is:
sk_matrix_t scale = {{sx, 0, 0, 0, sy, 0, 0, 0, 1}};
A matrix that translates by tx and ty is:
sk_matrix_t translate = {{1, 0, tx, 0, 1, ty, 0, 0, 1}};
A matrix that rotates around the origin by A radians:
sk_matrix_t rotate = {{cos(A), -sin(A), 0, sin(A), cos(A), 0, 0, 0, 1}};
Two matrixes can be concatinated by:
void concat_matrices(sk_matrix_t* dst, const sk_matrix_t* matrixU, const sk_matrix_t* matrixV) { const float* u = matrixU->mat; const float* v = matrixV->mat; sk_matrix_t result = {{ u[0] * v[0] + u[1] * v[3] + u[2] * v[6], u[0] * v[1] + u[1] * v[4] + u[2] * v[7], u[0] * v[2] + u[1] * v[5] + u[2] * v[8], u[3] * v[0] + u[4] * v[3] + u[5] * v[6], u[3] * v[1] + u[4] * v[4] + u[5] * v[7], u[3] * v[2] + u[4] * v[5] + u[5] * v[8], u[6] * v[0] + u[7] * v[3] + u[8] * v[6], u[6] * v[1] + u[7] * v[4] + u[8] * v[7], u[6] * v[2] + u[7] * v[5] + u[8] * v[8] }}; dst = result; }
Pointer.CustomDeallocator, Pointer.Deallocator, Pointer.NativeDeallocator, Pointer.ReferenceCounter| Constructor and Description |
|---|
sk_matrix_t()
Default native constructor.
|
sk_matrix_t(long size)
Native array allocator.
|
sk_matrix_t(Pointer p)
Pointer cast constructor.
|
| Modifier and Type | Method and Description |
|---|---|
FloatPointer |
mat() |
float |
mat(int i) |
sk_matrix_t |
mat(int i,
float setter) |
sk_matrix_t |
position(long position) |
address, asBuffer, asByteBuffer, availablePhysicalBytes, calloc, capacity, capacity, close, deallocate, deallocate, deallocateReferences, deallocator, deallocator, equals, fill, formatBytes, free, hashCode, isNull, limit, limit, malloc, maxBytes, maxPhysicalBytes, memchr, memcmp, memcpy, memmove, memset, offsetof, parseBytes, physicalBytes, position, put, realloc, referenceCount, releaseReference, retainReference, setNull, sizeof, toString, totalBytes, totalPhysicalBytes, withDeallocator, zeropublic sk_matrix_t()
public sk_matrix_t(long size)
Pointer.position(long).public sk_matrix_t(Pointer p)
Pointer.Pointer(Pointer).public sk_matrix_t position(long position)
public float mat(int i)
public sk_matrix_t mat(int i, float setter)
@MemberGetter public FloatPointer mat()
Copyright © 2019. All rights reserved.