base/transformmatrix
2차원 어파인 변환 행렬. (Canvas2D 호환 3x2 형식)
2D affine transform matrix. (3x2 form compatible with Canvas2D)
TransformMatrixextends Object
2차원 어파인 변환 행렬. (Canvas2D 호환 3x2 형식)
- | a c e | | b d f |
- 점 변환: x' = a*x + c*y + e, y' = b*x + d*y + f
2D affine transform matrix. (3x2 form compatible with Canvas2D)
- | a c e | | b d f |
- Point transform: x' = a*x + c*y + e, y' = b*x + d*y + f
import { TransformMatrix } from "./build/vanilla.js";
const transformMatrix = new TransformMatrix();
transformMatrix.translate(10, 20);
transformMatrix.scale(2, 2);
const point = transformMatrix.transformPoint(1, 1);
console.log(point.x, point.y);생성.
Constructor.
a 성분 반환 프로퍼티.
Property that returns the a component.
반환Returnsnumber a 성분. (x 의 x 방향 크기, 가로 배율 겸 회전 성분)The a component. (x scale and rotation part)
짝Counterpart: vanilla-engine TransformMatrix.a
b 성분 반환 프로퍼티.
Property that returns the b component.
반환Returnsnumber b 성분. (x 의 y 방향 기울기, 회전 성분)The b component. (y shear and rotation part)
짝Counterpart: vanilla-engine TransformMatrix.b
c 성분 반환 프로퍼티.
Property that returns the c component.
반환Returnsnumber c 성분. (y 의 x 방향 기울기, 회전 성분)The c component. (x shear and rotation part)
짝Counterpart: vanilla-engine TransformMatrix.c
d 성분 반환 프로퍼티.
Property that returns the d component.
반환Returnsnumber d 성분. (y 의 y 방향 크기, 세로 배율 겸 회전 성분)The d component. (y scale and rotation part)
짝Counterpart: vanilla-engine TransformMatrix.d
e 성분 반환 프로퍼티.
Property that returns the e component.
반환Returnsnumber e 성분. (x 방향 이동량)The e component. (x translation)
짝Counterpart: vanilla-engine TransformMatrix.e
f 성분 반환 프로퍼티.
Property that returns the f component.
반환Returnsnumber f 성분. (y 방향 이동량)The f component. (y translation)
짝Counterpart: vanilla-engine TransformMatrix.f
항등 행렬로 재설정.
Resets to the identity matrix.
짝Counterpart: vanilla-engine TransformMatrix.set_identity
행렬 성분 직접 설정. (Canvas2D setTransform 인자 순서와 동일)
Sets the matrix components directly. (same argument order as Canvas2D setTransform)
- anumber
- 행렬의 a 성분.The a component of the matrix.
- bnumber
- 행렬의 b 성분.The b component of the matrix.
- cnumber
- 행렬의 c 성분.The c component of the matrix.
- dnumber
- 행렬의 d 성분.The d component of the matrix.
- enumber
- 행렬의 e 성분. (x 방향 이동량)The e component of the matrix. (x translation)
- fnumber
- 행렬의 f 성분. (y 방향 이동량)The f component of the matrix. (y translation)
짝Counterpart: vanilla-engine TransformMatrix.set_transform
다른 행렬의 성분 복사.
Copies the components of another matrix.
- otherTransformMatrix
- 성분을 복사해 올 행렬.The matrix to copy the components from.
짝Counterpart: vanilla-engine TransformMatrix.copy_from
이동 변환 누적. (Canvas2D translate 와 동일한 로컬 공간 우측 곱)
Accumulates a translation. (local-space right multiply, same as Canvas2D translate)
- xnumber
- x 방향 이동량.Translation along x.
- ynumber
- y 방향 이동량.Translation along y.
짝Counterpart: vanilla-engine TransformMatrix.translate
회전 변환 누적. (Canvas2D rotate 와 동일한 로컬 공간 우측 곱)
Accumulates a rotation. (local-space right multiply, same as Canvas2D rotate)
- radiannumber
- 회전각. (라디안)Rotation angle. (radians)
짝Counterpart: vanilla-engine TransformMatrix.rotate
크기 변환 누적. (Canvas2D scale 과 동일한 로컬 공간 우측 곱)
Accumulates a scale. (local-space right multiply, same as Canvas2D scale)
- xnumber
- x 방향 배율.Scale along x.
- ynumber
- y 방향 배율.Scale along y.
짝Counterpart: vanilla-engine TransformMatrix.scale
다른 행렬을 우측에 곱해 누적. (this = this x other)
Accumulates by multiplying another matrix on the right. (this = this x other)
- otherTransformMatrix
- 우측에 곱할 행렬.The matrix multiplied on the right.
짝Counterpart: vanilla-engine TransformMatrix.multiply
역행렬. (새 행렬을 돌려주고 이 행렬은 그대로 둔다, 행렬식이 0 이면 null)
Inverse matrix. (returns a new matrix and leaves this one as is, null if the determinant is 0)
반환ReturnsTransformMatrix | null 역행렬. 행렬식이 0 이면 null.The inverse matrix, or null when the determinant is 0.
짝Counterpart: vanilla-engine TransformMatrix.invert
import { TransformMatrix } from "./build/vanilla.js";
const transformMatrix = new TransformMatrix();
transformMatrix.translate(10, 20);
const inverseMatrix = transformMatrix.invert();
const point = inverseMatrix.transformPoint(10, 20);
console.log(point.x, point.y);점 변환.
Transforms a point.
- xnumber
- 변환할 점의 x 좌표.The x coordinate of the point to transform.
- ynumber
- 변환할 점의 y 좌표.The y coordinate of the point to transform.
반환Returns{ x: number, y: number } 변환된 점.The transformed point.
짝Counterpart: vanilla-engine TransformMatrix.transform_point
행렬이 담고 있는 축별 스케일 중 최대값 반환. (텍스트 선명도 계산용)
Returns the largest of the per-axis scales in the matrix. (for text sharpness)
반환Returnsnumber x 축과 y 축 배율 중 큰 값.The larger of the x-axis and y-axis scales.
짝Counterpart: vanilla-engine TransformMatrix.get_maximum_scale
mat3 유니폼 업로드용 열우선(column-major) 배열 기록.
Writes a column-major array for uploading a mat3 uniform.
- targetFloat32Array
- 기록할 길이 9 이상의 배열.The array to write to, length 9 or more.
짝Counterpart: vanilla-engine TransformMatrix.write_to_float32_array