diff --git a/package.json b/package.json index 9b713e2..eaec6e2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@next2d/framework", "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.", - "version": "3.0.7", + "version": "3.0.8", "homepage": "https://next2d.app", "bugs": "https://github.com/Next2D/Framework/issues/new", "author": "Toshiyuki Ienaga (https://github.com/ienaga/)", @@ -32,18 +32,18 @@ }, "devDependencies": { "@eslint/eslintrc": "^3.3.1", - "@eslint/js": "^9.25.1", - "@types/node": "^22.15.3", - "@typescript-eslint/eslint-plugin": "^8.31.1", - "@typescript-eslint/parser": "^8.31.1", - "@vitest/web-worker": "^3.1.2", - "eslint": "^9.25.1", + "@eslint/js": "^9.28.0", + "@types/node": "^22.15.29", + "@typescript-eslint/eslint-plugin": "^8.33.0", + "@typescript-eslint/parser": "^8.33.0", + "@vitest/web-worker": "^3.1.4", + "eslint": "^9.28.0", "eslint-plugin-unused-imports": "^4.1.4", - "globals": "^16.0.0", + "globals": "^16.2.0", "jsdom": "^26.1.0", "typescript": "^5.8.3", - "vite": "^6.3.4", - "vitest": "^3.1.2", + "vite": "^6.3.5", + "vitest": "^3.1.4", "vitest-webgl-canvas-mock": "^1.1.0" }, "peerDependencies": { diff --git a/src/domain/screen/Capture/service/AddScreenCaptureService.test.ts b/src/domain/screen/Capture/service/AddScreenCaptureService.test.ts index 668c070..4494622 100644 --- a/src/domain/screen/Capture/service/AddScreenCaptureService.test.ts +++ b/src/domain/screen/Capture/service/AddScreenCaptureService.test.ts @@ -34,7 +34,7 @@ describe("AddScreenCaptureService Test", () => expect(root.numChildren).toBe(0); expect(root.mouseChildren).toBe(true); await execute(); - expect(root.numChildren).toBe(2); + expect(root.numChildren).toBe(1); expect(root.mouseChildren).toBe(false); }); }); \ No newline at end of file diff --git a/src/domain/screen/Capture/service/AddScreenCaptureService.ts b/src/domain/screen/Capture/service/AddScreenCaptureService.ts index da4097b..b21f341 100644 --- a/src/domain/screen/Capture/service/AddScreenCaptureService.ts +++ b/src/domain/screen/Capture/service/AddScreenCaptureService.ts @@ -41,33 +41,46 @@ export const execute = async (): Promise => */ root.mouseChildren = false; - const canvas = await next2d.captureToCanvas(root, { - "matrix": new Matrix(stage.rendererScale, 0, 0, stage.rendererScale, 0, 0) - }); + const scale = stage.rendererScale; + const config = $getConfig(); + const width = config.stage.width; + const height = config.stage.height; - const rectangle = root.getBounds(); - const bitmapData = new BitmapData(canvas.width, canvas.height); + const tx = (stage.rendererWidth - stage.stageWidth * scale) / 2; + const ty = (stage.rendererHeight - stage.stageHeight * scale) / 2; - bitmapData.canvas = canvas; + /** + * 現在の描画をcanvasに転写 + * Transfer the current drawing to canvas + */ + const rectangle = root.getBounds(); + if (rectangle.width > 0 && rectangle.height > 0) { - const bitmap = new Shape(); - bitmap.x = rectangle.x; - bitmap.y = rectangle.y; - if (stage.rendererScale !== 1) { - bitmap.scaleX = 1 / stage.rendererScale; - bitmap.scaleY = 1 / stage.rendererScale; - } + const canvas = await next2d.captureToCanvas(root, { + "matrix": new Matrix( + scale, 0, 0, scale, + -rectangle.x * scale, + -rectangle.y * scale + ) + }); - bitmap.setBitmapBuffer( - canvas.width, canvas.height, - bitmapData.buffer as Uint8Array - ); + const bitmapData = new BitmapData(canvas.width, canvas.height); + bitmapData.canvas = canvas; - root.addChild(bitmap); + const bitmap = new Shape(); + bitmap.setBitmapBuffer( + canvas.width, canvas.height, + bitmapData.buffer as Uint8Array + ); + + bitmap.scaleX = 1 / scale; + bitmap.scaleY = 1 / scale; + bitmap.x = -tx / scale; + bitmap.y = -ty / scale; + + root.addChild(bitmap); + } - const config = $getConfig(); - const width = config.stage.width; - const height = config.stage.height; if (shape.width !== width || shape.width !== height) { shape .graphics @@ -77,19 +90,15 @@ export const execute = async (): Promise => .endFill(); } - const scale = stage.rendererScale; - - const tx = (stage.rendererWidth - stage.stageWidth * scale) / 2; if (tx && $cacheX !== tx) { $cacheX = tx; - shape.scaleX = (width + tx * 2 / scale) / width; + shape.width = stage.rendererWidth / scale; shape.x = -tx / scale; } - const ty = (stage.rendererHeight - stage.stageHeight * scale) / 2; if (ty && $cacheY !== ty) { $cacheY = ty; - shape.scaleY = (height + ty * 2 / scale) / height; + shape.height = stage.rendererHeight / scale; shape.y = -ty / scale; }