Skip to content
This repository was archived by the owner on Jul 26, 2025. It is now read-only.

Commit d371091

Browse files
committed
fix: fix other functions to accept 3x3
1 parent 04520ab commit d371091

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

src/geometry/__tests__/transform.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,5 +121,5 @@ test('should throw if matrix has wrong size', () => {
121121
];
122122
expect(() => {
123123
img.transform(translation);
124-
}).toThrow('transformation matrix must be 2x3. Received 2x4');
124+
}).toThrow('transformation matrix must be 2x3 or 3x3. Received 2x4');
125125
});

src/geometry/transform.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export function transform(
128128

129129
if (!isValidMatrix(transformMatrix)) {
130130
throw new TypeError(
131-
`transformation matrix must be 3x3 or 2x3. Received ${transformMatrix.length}x${transformMatrix[1].length}`,
131+
`transformation matrix must be 2x3 or 3x3. Received ${transformMatrix.length}x${transformMatrix[1].length}`,
132132
);
133133
}
134134
if (transformMatrix.length === 2) {

src/geometry/transformRotate.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export function transformRotate(
4747
* @param angle - Angle in degrees.
4848
* @param center - Center point of the image.
4949
* @param scale - Scaling factor.
50-
* @returns 2 x 3 rotation matrix.
50+
* @returns 3 x 3 rotation matrix.
5151
*/
5252
function getRotationMatrix(
5353
angle: number,
@@ -60,5 +60,6 @@ function getRotationMatrix(
6060
return [
6161
[cos, sin, (1 - cos) * center.column - sin * center.row],
6262
[-sin, cos, sin * center.column + (1 - cos) * center.row],
63+
[0, 0, 1],
6364
];
6465
}

0 commit comments

Comments
 (0)