Skip to content

Commit f49d3ef

Browse files
committed
#145 ローディング処理を改修
1 parent 8e7f166 commit f49d3ef

File tree

3 files changed

+46
-37
lines changed

3 files changed

+46
-37
lines changed

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@next2d/framework",
33
"description": "Next2D Framework is designed according to the principles of clean architecture, domain-driven development, test-driven development, and MVVM, with an emphasis on flexibility, scalability, and maintainability, and a design methodology that keeps each layer loosely coupled.",
4-
"version": "3.0.7",
4+
"version": "3.0.8",
55
"homepage": "https://next2d.app",
66
"bugs": "https://github.com/Next2D/Framework/issues/new",
77
"author": "Toshiyuki Ienaga <[email protected]> (https://github.com/ienaga/)",
@@ -32,18 +32,18 @@
3232
},
3333
"devDependencies": {
3434
"@eslint/eslintrc": "^3.3.1",
35-
"@eslint/js": "^9.27.0",
36-
"@types/node": "^22.15.18",
37-
"@typescript-eslint/eslint-plugin": "^8.32.1",
38-
"@typescript-eslint/parser": "^8.32.1",
39-
"@vitest/web-worker": "^3.1.3",
40-
"eslint": "^9.27.0",
35+
"@eslint/js": "^9.28.0",
36+
"@types/node": "^22.15.29",
37+
"@typescript-eslint/eslint-plugin": "^8.33.0",
38+
"@typescript-eslint/parser": "^8.33.0",
39+
"@vitest/web-worker": "^3.1.4",
40+
"eslint": "^9.28.0",
4141
"eslint-plugin-unused-imports": "^4.1.4",
42-
"globals": "^16.1.0",
42+
"globals": "^16.2.0",
4343
"jsdom": "^26.1.0",
4444
"typescript": "^5.8.3",
4545
"vite": "^6.3.5",
46-
"vitest": "^3.1.3",
46+
"vitest": "^3.1.4",
4747
"vitest-webgl-canvas-mock": "^1.1.0"
4848
},
4949
"peerDependencies": {

src/domain/screen/Capture/service/AddScreenCaptureService.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe("AddScreenCaptureService Test", () =>
3434
expect(root.numChildren).toBe(0);
3535
expect(root.mouseChildren).toBe(true);
3636
await execute();
37-
expect(root.numChildren).toBe(2);
37+
expect(root.numChildren).toBe(1);
3838
expect(root.mouseChildren).toBe(false);
3939
});
4040
});

src/domain/screen/Capture/service/AddScreenCaptureService.ts

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -41,33 +41,46 @@ export const execute = async (): Promise<void> =>
4141
*/
4242
root.mouseChildren = false;
4343

44-
const canvas = await next2d.captureToCanvas(root, {
45-
"matrix": new Matrix(stage.rendererScale, 0, 0, stage.rendererScale, 0, 0)
46-
});
44+
const scale = stage.rendererScale;
45+
const config = $getConfig();
46+
const width = config.stage.width;
47+
const height = config.stage.height;
4748

48-
const rectangle = root.getBounds();
49-
const bitmapData = new BitmapData(canvas.width, canvas.height);
49+
const tx = (stage.rendererWidth - stage.stageWidth * scale) / 2;
50+
const ty = (stage.rendererHeight - stage.stageHeight * scale) / 2;
5051

51-
bitmapData.canvas = canvas;
52+
/**
53+
* 現在の描画をcanvasに転写
54+
* Transfer the current drawing to canvas
55+
*/
56+
const rectangle = root.getBounds();
57+
if (rectangle.width > 0 && rectangle.height > 0) {
5258

53-
const bitmap = new Shape();
54-
bitmap.x = rectangle.x;
55-
bitmap.y = rectangle.y;
56-
if (stage.rendererScale !== 1) {
57-
bitmap.scaleX = 1 / stage.rendererScale;
58-
bitmap.scaleY = 1 / stage.rendererScale;
59-
}
59+
const canvas = await next2d.captureToCanvas(root, {
60+
"matrix": new Matrix(
61+
scale, 0, 0, scale,
62+
-rectangle.x * scale,
63+
-rectangle.y * scale
64+
)
65+
});
6066

61-
bitmap.setBitmapBuffer(
62-
canvas.width, canvas.height,
63-
bitmapData.buffer as Uint8Array
64-
);
67+
const bitmapData = new BitmapData(canvas.width, canvas.height);
68+
bitmapData.canvas = canvas;
6569

66-
root.addChild(bitmap);
70+
const bitmap = new Shape();
71+
bitmap.setBitmapBuffer(
72+
canvas.width, canvas.height,
73+
bitmapData.buffer as Uint8Array
74+
);
75+
76+
bitmap.scaleX = 1 / scale;
77+
bitmap.scaleY = 1 / scale;
78+
bitmap.x = -tx / scale;
79+
bitmap.y = -ty / scale;
80+
81+
root.addChild(bitmap);
82+
}
6783

68-
const config = $getConfig();
69-
const width = config.stage.width;
70-
const height = config.stage.height;
7184
if (shape.width !== width || shape.width !== height) {
7285
shape
7386
.graphics
@@ -77,19 +90,15 @@ export const execute = async (): Promise<void> =>
7790
.endFill();
7891
}
7992

80-
const scale = stage.rendererScale;
81-
82-
const tx = (stage.rendererWidth - stage.stageWidth * scale) / 2;
8393
if (tx && $cacheX !== tx) {
8494
$cacheX = tx;
85-
shape.scaleX = (width + tx * 2 / scale) / width;
95+
shape.width = stage.rendererWidth / scale;
8696
shape.x = -tx / scale;
8797
}
8898

89-
const ty = (stage.rendererHeight - stage.stageHeight * scale) / 2;
9099
if (ty && $cacheY !== ty) {
91100
$cacheY = ty;
92-
shape.scaleY = (height + ty * 2 / scale) / height;
101+
shape.height = stage.rendererHeight / scale;
93102
shape.y = -ty / scale;
94103
}
95104

0 commit comments

Comments
 (0)