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
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -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 <[email protected]> (https://github.com/ienaga/)",
Expand Down Expand Up @@ -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": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
63 changes: 36 additions & 27 deletions src/domain/screen/Capture/service/AddScreenCaptureService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,33 +41,46 @@ export const execute = async (): Promise<void> =>
*/
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
Expand All @@ -77,19 +90,15 @@ export const execute = async (): Promise<void> =>
.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;
}

Expand Down