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
86 changes: 43 additions & 43 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<script>
window.addEventListener("DOMContentLoaded", async () =>
{
// next2d.load("develop");
await next2d.load("develop");

// const root = await next2d.createRootMovieClip(400, 400, 60, {
// bgColor: "#0000ff"
Expand Down Expand Up @@ -167,49 +167,49 @@
// }, 3000);


const count = 8000;
const root = next2d
.createRootMovieClip(1000, 416, 60)
.then((root) =>
{
const { Shape } = next2d.display;
// const count = 8000;
// const root = next2d
// .createRootMovieClip(1000, 416, 60)
// .then((root) =>
// {
// const { Shape } = next2d.display;

const rects = [];
for (let i = 0; i < count; i++) {
const x = Math.random() * 1000;
const y = Math.random() * 416;
const size = 10 + Math.random() * 40;
const speed = 1 + Math.random();

var rect = new Shape();

rect
.graphics
.beginFill("#fff")
.lineStyle(1, "#000")
.drawRect(0, 0, size, size);

rect.x = x;
rect.y = y;

root.addChild(rect);

rects.push({ size, speed, el: rect });
}

root.addEventListener("enterFrame", () =>
{
for (let i = 0; i < count; i++) {
const rect = rects[i];

if (rect.el.x + rect.size < 0) {
rect.el.x = 1000 + rect.size / 2;
}

rect.el.x -= rect.speed;
}
});
});
// const rects = [];
// for (let i = 0; i < count; i++) {
// const x = Math.random() * 1000;
// const y = Math.random() * 416;
// const size = 10 + Math.random() * 40;
// const speed = 1 + Math.random();

// var rect = new Shape();

// rect
// .graphics
// .beginFill("#fff")
// .lineStyle(1, "#000")
// .drawRect(0, 0, size, size);

// rect.x = x;
// rect.y = y;

// root.addChild(rect);

// rects.push({ size, speed, el: rect });
// }

// root.addEventListener("enterFrame", () =>
// {
// for (let i = 0; i < count; i++) {
// const rect = rects[i];

// if (rect.el.x + rect.size < 0) {
// rect.el.x = 1000 + rect.size / 2;
// }

// rect.el.x -= rect.speed;
// }
// });
// });

});
</script>
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next2d/player",
"version": "2.1.5",
"version": "2.2.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 @@ -62,7 +62,7 @@
"rollup": "^4.40.0",
"tslib": "^2.8.1",
"typescript": "^5.8.3",
"vite": "^6.3.0",
"vite": "^6.3.2",
"vitest": "^3.1.1",
"vitest-webgl-canvas-mock": "^1.1.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ describe("CacheStoreGenerateKeysService.js test", () =>
{
it("test case1", () =>
{
expect(execute(0.25, 0.5, 0)).toBe(15480923);
expect(execute(0.25, 0.5, 0)).toBe(13038674);
});

it("test case2", () =>
{
expect(execute(0.25, 0.5, 0.3)).toBe(6600597);
expect(execute(0.25, 0.5, 0.3)).toBe(6614284);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
export const execute = (x_scale: number, y_scale: number, alpha: number): number =>
{
const values = [x_scale * 10000, y_scale * 10000];
const values = [x_scale * 10, y_scale * 10];
if (alpha) {
values.push(alpha * 100);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ describe("CanvasRegisterEventUseCase.js test", () =>
} as unknown as HTMLCanvasElement;

execute(MockCanvas);
expect(results.length).toBe(6);
expect(results.length).toBe(7);

expect(results[0]).toBe(PointerEvent.POINTER_UP);
expect(results[1]).toBe(PointerEvent.POINTER_DOWN);
expect(results[2]).toBe(PointerEvent.POINTER_UP);
expect(results[3]).toBe(PointerEvent.POINTER_MOVE);
expect(results[4]).toBe(PointerEvent.POINTER_LEAVE);
expect(results[5]).toBe(WheelEvent.WHEEL);
expect(results[3]).toBe(PointerEvent.POINTER_CANCEl);
expect(results[4]).toBe(PointerEvent.POINTER_MOVE);
expect(results[5]).toBe(PointerEvent.POINTER_LEAVE);
expect(results[6]).toBe(WheelEvent.WHEEL);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const execute = (canvas: HTMLCanvasElement): void =>

canvas.addEventListener(PointerEvent.POINTER_DOWN, canvasPointerDownEventUseCase as EventListener, { "passive": false });
canvas.addEventListener(PointerEvent.POINTER_UP, canvasPointerUpEventUseCase as EventListener);
canvas.addEventListener(PointerEvent.POINTER_CANCEl, canvasPointerUpEventUseCase as EventListener);
canvas.addEventListener(PointerEvent.POINTER_MOVE, canvasPointerMoveEventUseCase as EventListener, { "passive": false });
canvas.addEventListener(PointerEvent.POINTER_LEAVE, canvasPointerLeaveEventUseCase as EventListener);
canvas.addEventListener(WheelEvent.WHEEL, canvasWheelEventUseCase as EventListener);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const execute = <D extends DisplayObject>(display_object: D): number =>
xScale = +value.slice(0, index);
}

xScale = Math.round(xScale * 10000) / 10000;
xScale = Math.round(xScale * 100) / 100;
}

return 0 > matrix[0] ? xScale * -1 : xScale;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const execute = <D extends DisplayObject>(display_object: D): number =>
if (index !== -1) {
yScale = +value.slice(0, index);
}
yScale = Math.round(yScale * 10000) / 10000;
yScale = Math.round(yScale * 100) / 100;
}

return 0 > matrix[0] ? yScale * -1 : yScale;
Expand Down
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.33329999446868896);
expect(rawData[3]).toBe(0.33000001311302185);
expect(rawData[4]).toBe(0);
expect(rawData[5]).toBe(0);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe("DisplayObjectSetScaleXUseCase.js test", () =>
execute(displayObject, 2.2001231231005124151);

expect(displayObject.changed).toBe(true);
expect(displayObject.$scaleX).toBe(2.2001);
expect(displayObject.$scaleX).toBe(2.2);
});

it("execute test case4", () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const execute = <D extends DisplayObject>(display_object: D, scale_x: num
if (index !== -1) {
scale_x = +value.slice(0, index);
}
scale_x = Math.round(scale_x * 10000) / 10000;
scale_x = Math.round(scale_x * 100) / 100;
}

if (display_object.$scaleX === scale_x) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe("DisplayObjectSetScaleYUseCase.js test", () =>
execute(displayObject, 2.2001231231005124151);

expect(displayObject.changed).toBe(true);
expect(displayObject.$scaleY).toBe(2.2001);
expect(displayObject.$scaleY).toBe(2.2);
});

it("execute test case4", () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const execute = <D extends DisplayObject>(display_object: D, scale_y: num
if (index !== -1) {
scale_y = +value.slice(0, index);
}
scale_y = Math.round(scale_y * 10000) / 10000;
scale_y = Math.round(scale_y * 100) / 100;
}

if (display_object.$scaleY === scale_y) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ describe("DisplayObjectSetWidthUseCase.js test", () =>
throw new Error("rawData is null");
}

expect(rawData[0]).toBe(0.4544999897480011);
expect(rawData[0]).toBe(0.44999998807907104);
expect(rawData[1]).toBe(0);
expect(rawData[2]).toBe(0);
expect(rawData[3]).toBe(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,12 @@ export const execute = (
const xScale = Math.round(Math.sqrt(
tMatrix[0] * tMatrix[0]
+ tMatrix[1] * tMatrix[1]
) * 10000) / 10000;
) * 10) / 10;

const yScale = Math.round(Math.sqrt(
tMatrix[2] * tMatrix[2]
+ tMatrix[3] * tMatrix[3]
) * 10000) / 10000;
) * 10) / 10;

if (!shape.isBitmap
&& !shape.cacheKey
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,12 @@ export const execute = (
const xScale = Math.round(Math.sqrt(
tMatrix[0] * tMatrix[0]
+ tMatrix[1] * tMatrix[1]
) * 10000) / 10000;
) * 10) / 10;

const yScale = Math.round(Math.sqrt(
tMatrix[2] * tMatrix[2]
+ tMatrix[3] * tMatrix[3]
) * 10000) / 10000;
) * 10) / 10;

if (text_field.changed
&& !text_field.cacheKey
Expand Down
13 changes: 13 additions & 0 deletions packages/events/src/PointerEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,17 @@ export class PointerEvent extends Event
{
return "pointerup";
}

/**
* @description ポインターのキャンセル時に発生します。
* Occurs when the pointer is canceled.
*
* @return {string}
* @const
* @static
*/
static get POINTER_CANCEl (): string
{
return "pointercancel";
}
}
14 changes: 10 additions & 4 deletions packages/renderer/src/Shape/usecase/ShapeRenderUseCase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ export const execute = (render_queue: Float32Array, index: number): number =>
const xScale = Math.round(Math.sqrt(
matrix[0] * matrix[0]
+ matrix[1] * matrix[1]
) * 10000) / 10000;
) * 10) / 10;

const yScale = Math.round(Math.sqrt(
matrix[2] * matrix[2]
+ matrix[3] * matrix[3]
) * 10000) / 10000;
) * 10) / 10;

let node: Node;
const hasCache = render_queue[index++];
Expand Down Expand Up @@ -205,8 +205,14 @@ export const execute = (render_queue: Float32Array, index: number): number =>
const radianY = Math.atan2(-matrix[2], matrix[3]);
if (radianX || radianY) {

const tx = xMin * xScale;
const ty = yMin * yScale;
const tx = xMin * Math.sqrt(
matrix[0] * matrix[0]
+ matrix[1] * matrix[1]
);
const ty = yMin * Math.sqrt(
matrix[2] * matrix[2]
+ matrix[3] * matrix[3]
);

const cosX = Math.cos(radianX);
const sinX = Math.sin(radianX);
Expand Down
14 changes: 10 additions & 4 deletions packages/renderer/src/TextField/usecase/TextFieldRenderUseCase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ export const execute = (render_queue: Float32Array, index: number): number =>
const xScale = Math.round(Math.sqrt(
matrix[0] * matrix[0]
+ matrix[1] * matrix[1]
) * 10000) / 10000;
) * 10) / 10;

const yScale = Math.round(Math.sqrt(
matrix[2] * matrix[2]
+ matrix[3] * matrix[3]
) * 10000) / 10000;
) * 10) / 10;

let node: Node;
const hasCache = render_queue[index++];
Expand Down Expand Up @@ -192,8 +192,14 @@ export const execute = (render_queue: Float32Array, index: number): number =>
const radianY = Math.atan2(-matrix[2], matrix[3]);
if (radianX || radianY) {

const tx = xMin * xScale;
const ty = yMin * yScale;
const tx = xMin * Math.sqrt(
matrix[0] * matrix[0]
+ matrix[1] * matrix[1]
);
const ty = yMin * Math.sqrt(
matrix[2] * matrix[2]
+ matrix[3] * matrix[3]
);

const cosX = Math.cos(radianX);
const sinX = Math.sin(radianX);
Expand Down
Loading