Skip to content

Commit 9cfc864

Browse files
committed
🐛 导出png时,图片内容留100px(世界坐标系距离)边距
1 parent 98dc9b2 commit 9cfc864

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

app/src/core/service/dataGenerateService/stageExportEngine/StageExportPng.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ export namespace StageExportPng {
1818
*/
1919
let cameraScaleWhenExport = 0.5;
2020

21+
const PADDING = 100;
22+
2123
export function changeCameraScaleWhenExport(scale: number) {
2224
cameraScaleWhenExport = scale;
2325
}
@@ -39,8 +41,8 @@ export namespace StageExportPng {
3941
// 创建完毕
4042

4143
const stageRect = StageManager.getBoundingRectangle();
42-
const topLeft = stageRect.leftTop;
43-
const bottomRight = stageRect.rightBottom;
44+
const topLeft = stageRect.leftTop.subtract(new Vector(PADDING, PADDING));
45+
const bottomRight = stageRect.rightBottom.add(new Vector(PADDING, PADDING));
4446
// 开始把画布内容渲染到新画布上
4547
Camera.targetScale = cameraScaleWhenExport;
4648
Camera.currentScale = cameraScaleWhenExport;
@@ -144,7 +146,7 @@ export namespace StageExportPng {
144146
resultCanvas.style.zIndex = "99999";
145147
resultCanvas.style.pointerEvents = "none";
146148

147-
const stageSize = StageManager.getSize();
149+
const stageSize = StageManager.getSize().add(new Vector(PADDING * 2, PADDING * 2));
148150
// 设置大小
149151
resultCanvas.width = stageSize.x * SCALE * cameraScaleWhenExport;
150152
resultCanvas.height = stageSize.y * SCALE * cameraScaleWhenExport;

0 commit comments

Comments
 (0)