Skip to content

Commit

Permalink
#154 feat: Matrixの移行準備
Browse files Browse the repository at this point in the history
  • Loading branch information
ienaga committed Jul 22, 2024
1 parent 38e450e commit f9b3e0c
Show file tree
Hide file tree
Showing 8 changed files with 212 additions and 163 deletions.
88 changes: 0 additions & 88 deletions __tests__/next2d/geom/MatrixTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,95 +46,7 @@ describe("Matrix.js namespace test", () =>

});

describe("Matrix.js property valid test and clone test", () =>
{

it("property success case1", () =>
{
let m = new Matrix();
m.a = 1.2;
m.b = 0.765;
m.c = -0.872;
m.d = -1.5;
m.tx = 10;
m.ty = -10;

expect(m.a).toBe(1.2000000476837158);
expect(m.b).toBe(0.7649999856948853);
expect(m.c).toBe(-0.871999979019165);
expect(m.d).toBe(-1.5);
expect(m.tx).toBe(10);
expect(m.ty).toBe(-10);
});

it("property success case2", () =>
{
let m = new Matrix();
// @ts-ignore
m.a = "1.2";
// @ts-ignore
m.b = "0.765";
// @ts-ignore
m.c = "-0.872";
// @ts-ignore
m.d = "-1.5";
// @ts-ignore
m.tx = "10";
// @ts-ignore
m.ty = "-10";

expect(m.a).toBe(1.2000000476837158);
expect(m.b).toBe(0.7649999856948853);
expect(m.c).toBe(-0.871999979019165);
expect(m.d).toBe(-1.5);
expect(m.tx).toBe(10);
expect(m.ty).toBe(-10);
});

it("valid and clone test", () =>
{
// valid
// @ts-ignore
let m1 = new Matrix("a", "b", "c", "d", "tx", "ty");
// @ts-ignore
m1.a = "a";
// @ts-ignore
m1.b = "b";
// @ts-ignore
m1.c = "c";
// @ts-ignore
m1.d = "d";
// @ts-ignore
m1.tx = "tx";
// @ts-ignore
m1.ty = "ty";

// clone matrix
let m2 = m1._$clone();
m2.a = 1.2;
m2.b = 0.765;
m2.c = -0.872;
m2.d = -1.5;
m2.tx = 10;
m2.ty = -10;

// origin
expect(m1.a).toBe(0);
expect(m1.b).toBe(0);
expect(m1.c).toBe(0);
expect(m1.d).toBe(0);
expect(m1.tx).toBe(0);
expect(m1.ty).toBe(0);

// clone
expect(m2.a).toBe(1.2000000476837158);
expect(m2.b).toBe(0.7649999856948853);
expect(m2.c).toBe(-0.871999979019165);
expect(m2.d).toBe(-1.5);
expect(m2.tx).toBe(10);
expect(m2.ty).toBe(-10);
});
});

describe("Matrix.js concat test", () =>
{
Expand Down
2 changes: 1 addition & 1 deletion packages/geom/src/ColorTransform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ export class ColorTransform
* @method
* @private
*/
_$multiplicationColor (a: Float32Array, b: Float32Array): Float32Array
_$multiplication (a: Float32Array, b: Float32Array): Float32Array
{
return $getFloat32Array(
a[0] * b[0],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { ColorTransform } from "../../ColorTransform";
*/
export const execute = (src: ColorTransform, dst: ColorTransform): void =>
{
const multiColor = src._$multiplicationColor(
const multiColor = src._$multiplication(
src._$colorTransform,
dst._$colorTransform
);
Expand Down
41 changes: 41 additions & 0 deletions packages/geom/src/Matrix.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { Matrix } from "./Matrix";
import { describe, expect, it } from "vitest";

describe("Matrix.js toString test", () =>
{
it("toString test1 success", () =>
{
const matrix = new Matrix();
expect(matrix.toString()).toBe("(a=1, b=0, c=0, d=1, tx=0, ty=0)");
});

it("toString test2 success", () =>
{
const matrix = new Matrix(2, 3, 4, 5, 6, 7);
expect(matrix.toString()).toBe("(a=2, b=3, c=4, d=5, tx=6, ty=7)");
});
});

describe("Matrix.js static toString test", () =>
{

it("static toString test", () =>
{
expect(Matrix.toString()).toBe("[class Matrix]");
});

});

describe("Matrix.js namespace test", () =>
{
it("namespace test public", () =>
{
const matrix = new Matrix();
expect(matrix.namespace).toBe("next2d.geom.Matrix");
});

it("namespace test static", () =>
{
expect(Matrix.namespace).toBe("next2d.geom.Matrix");
});
});
Loading

0 comments on commit f9b3e0c

Please sign in to comment.