Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 11 additions & 40 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,48 +33,19 @@
// DisplacementMapFilter
// } = next2d.filters;

// const image = new Image();
// image.addEventListener("load", () =>
// {
// const bitmapData = new BitmapData();
// bitmapData.image = image;

// const shape = root.addChild(new Shape());
// shape.x = 150;
// shape.y = 150;
// const shape = root.addChild(new Shape());
// shape.x = 150;
// shape.y = 150;

// shape.addEventListener(Event.COMPLETE, () =>
// {
// shape.scaleX = 0.5;
// shape.scaleY = 0.5;
// shape.filters = [
// // new BlurFilter(10, 10, 3),
// // new DropShadowFilter(20, 45, 0, 0.5),
// // new ColorMatrixFilter([
// // 0.393, 0.769, 0.189, 0, 0,
// // 0.349, 0.686, 0.168, 0, 0,
// // 0.272, 0.534, 0.131, 0, 0,
// // 0, 0, 0, 1, 0
// // ]),
// // new GlowFilter(0, 1, 30, 20, 1, 1),
// // new BevelFilter(4, 45, 0x0000ff, 1, 0, 1, 10, 10, 2, 1),
// // new GradientBevelFilter(80, 45, [0x0000ff, 0x00ff00, 0xff0000], [0, 0.5, 1], [0, 128, 255], 4, 4, 1, 1),
// // new GradientGlowFilter(4, 45, [0x000000, 0xffffff], [0, 1], [0, 255], 4, 4, 1, 1),
// // new ConvolutionFilter(3, 3, [
// // 0, -0.25, 0,
// // -0.25, 4, -0.25,
// // 0, -0.25, 0
// // ], 1, 3, false, false),
// new DisplacementMapFilter(
// bitmapData.buffer, bitmapData.width, bitmapData.height, 40, 40,
// 1, 4, 32, 32
// )
// ];
// });

// shape.src = "http://localhost:5173/json/image/logo.png";
// shape.addEventListener(Event.COMPLETE, () =>
// {
// shape.rotation = 190;
// shape.scaleX = 0.25;
// shape.scaleY = 0.25;
// console.log(shape.rotation);
// });
// image.src = "http://localhost:5173/json/image/image.png";

// shape.src = "http://localhost:5173/json/image/logo.png";

// const shape1 = root.addChild(new Shape());
// shape1.x = 150;
Expand Down
66 changes: 33 additions & 33 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next2d/player",
"version": "2.4.2",
"version": "2.5.0",
"description": "Experience the fast and beautiful anti-aliased rendering of WebGL. You can create rich, interactive graphics, cross-platform applications and games without worrying about browser or device compatibility.",
"author": "Toshiyuki Ienaga<ienaga@next2d.app> (https://github.com/ienaga/)",
"license": "MIT",
Expand Down Expand Up @@ -46,23 +46,23 @@
},
"devDependencies": {
"@eslint/eslintrc": "^3.3.1",
"@eslint/js": "^9.32.0",
"@eslint/js": "^9.33.0",
"@rollup/plugin-commonjs": "^28.0.6",
"@rollup/plugin-node-resolve": "^16.0.1",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^12.1.4",
"@types/node": "^24.2.0",
"@types/node": "^24.2.1",
"@typescript-eslint/eslint-plugin": "^8.39.0",
"@typescript-eslint/parser": "^8.39.0",
"@vitest/web-worker": "^3.2.4",
"eslint": "^9.32.0",
"eslint": "^9.33.0",
"eslint-plugin-unused-imports": "^4.1.4",
"globals": "^16.3.0",
"jsdom": "^26.1.0",
"rollup": "^4.46.2",
"tslib": "^2.8.1",
"typescript": "^5.9.2",
"vite": "^7.0.6",
"vite": "^7.1.1",
"vitest": "^3.2.4",
"vitest-webgl-canvas-mock": "^1.1.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,15 @@ describe("DisplayObjectGetScaleXUseCase.js test", () =>
};
expect(execute(displayObject)).toBe(1);
});

it("execute test case4", () =>
{
const displayObject = new DisplayObject();
displayObject.rotation = 286;
displayObject.scaleX = -1.17;
expect(execute(displayObject)).toBe(-1.17);

displayObject.scaleX = 0.65;
expect(execute(displayObject)).toBe(0.65);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ export const execute = <D extends DisplayObject>(display_object: D): number =>
return 1;
}

const xScale = Math.round(Math.sqrt(
matrix[0] * matrix[0]
+ matrix[1] * matrix[1]
) * 10000) / 10000;
const EPS = 1e-12;
const signX = (Math.abs(matrix[0]) >= EPS ? Math.sign(matrix[0]) : Math.sign(matrix[1])) || 1;
const xScale = Math.hypot(matrix[0], matrix[1]);

return 0 > matrix[0] ? xScale * -1 : xScale;
return Math.round(xScale * signX * 10000) / 10000;
};
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,29 @@ describe("DisplayObjectGetScaleYUseCase.js test", () =>
};
expect(execute(displayObject)).toBe(1);
});

it("execute test case4", () =>
{
const displayObject = new DisplayObject();
displayObject.rotation = 190;
displayObject.scaleY = -1.56;
expect(execute(displayObject)).toBe(-1.56);
displayObject.scaleY = 0.56;

const matrix = displayObject.$matrix;
if (!matrix) {
throw new Error("Matrix is not defined");
}

const rawData = matrix.rawData;
expect(rawData[0]).toBe(-0.9848077297210693);
expect(rawData[1]).toBe(-0.1736481785774231);
expect(rawData[2]).toBe(-0.09724298119544983);
expect(rawData[3]).toBe(0.5514923334121704);
expect(rawData[4]).toBe(0);
expect(rawData[5]).toBe(0);

expect(execute(displayObject)).toBe(0.56);

});
});
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ export const execute = <D extends DisplayObject>(display_object: D): number =>
return 1;
}

const yScale = Math.round(Math.sqrt(
matrix[2] * matrix[2]
+ matrix[3] * matrix[3]
) * 10000) / 10000;
const EPS = 1e-12;

return 0 > matrix[3] ? yScale * -1 : yScale;
const sxAbs = Math.hypot(matrix[0], matrix[1]);
const signX = (Math.abs(matrix[0]) >= EPS ? Math.sign(matrix[0]) : Math.sign(matrix[1])) || 1;
return Math.round((matrix[0] * matrix[3] - matrix[1] * matrix[2]) / (sxAbs * signX) * 10000) / 10000;
};
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe("DisplayObjectSetHeightUseCase.js test", () =>
expect(rawData[0]).toBe(1);
expect(rawData[1]).toBe(0);
expect(rawData[2]).toBe(0);
expect(rawData[3]).toBe(0.3333333432674408);
expect(rawData[3]).toBe(0.33329999446868896);
expect(rawData[4]).toBe(0);
expect(rawData[5]).toBe(0);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const $Deg2Rad: number = Math.PI / 180;
*/
export const execute = <D extends DisplayObject>(display_object: D, rotation: number): void =>
{
rotation = $clamp(rotation % 360, 0 - 360, 360, 0);
rotation = $clamp(rotation % 360, -360, 360, 0);
Copy link

Copilot AI Aug 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The expression 0 - 360 was changed to -360. While functionally equivalent, this change removes an unnecessary arithmetic operation that could have been confusing. However, consider using a named constant for the rotation bounds to improve readability.

Suggested change
rotation = $clamp(rotation % 360, -360, 360, 0);
rotation = $clamp(rotation % 360, MIN_ROTATION_DEGREES, MAX_ROTATION_DEGREES, 0);

Copilot uses AI. Check for mistakes.
if (display_object.$rotation === rotation) {
return ;
}
Expand Down Expand Up @@ -66,6 +66,8 @@ export const execute = <D extends DisplayObject>(display_object: D, rotation: nu
}
}

display_object.$scaleX = null;
display_object.$scaleY = null;
display_object.$rotation = rotation;
displayObjectApplyChangesService(display_object);
};
Loading
Loading