Skip to content

Commit fda9edb

Browse files
committed
🧪 尝试添加导出png图片的背景但失败,增加透明背景的提示语
1 parent eed34d9 commit fda9edb

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ export namespace StageExportPng {
4343
// 画布背景
4444
if (isHaveBackground) {
4545
resultCtx.fillStyle = StageStyleManager.currentStyle.Background.toNewAlpha(1).toString();
46-
resultCtx.fillRect(0, 0, stageRect.size.x, stageRect.size.y);
46+
console.log("background", resultCtx.fillStyle, stageRect);
47+
// resultCtx.roundRect(0, 0, Math.floor(stageRect.size.x * 10), Math.floor(stageRect.size.y * 10));
48+
resultCtx.roundRect(-10000, 10000, 20000, 20000);
49+
// 奇怪了
50+
resultCtx.fill();
4751
}
4852
// 开始把画布内容渲染到新画布上
4953
Camera.targetScale = cameraScaleWhenExport;
@@ -54,9 +58,9 @@ export namespace StageExportPng {
5458
for (let y = topLeft.y; y <= bottomRight.y; y += viewRect.size.y) {
5559
for (let x = topLeft.x; x <= bottomRight.x; x += viewRect.size.x) {
5660
// 先移动再暂停等待
57-
await sleep(50);
61+
await sleep(20);
5862
Camera.location = new Vector(x + viewRect.size.x / 2, y + viewRect.size.y / 2);
59-
await sleep(50);
63+
await sleep(20);
6064
const imageData = Canvas.ctx.getImageData(0, 0, viewRect.size.x * SCALE, viewRect.size.y * SCALE);
6165
resultCtx.putImageData(
6266
imageData,

app/src/pages/_fixed_panel/_export_png_panel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export default function ExportPNGPanel() {
5959
>
6060
<h2>导出png图片</h2>
6161
<div
62-
className="bg-panel-bg flex h-96 w-full items-center justify-center overflow-auto rounded-md"
62+
className="flex h-96 w-full items-center justify-center overflow-auto rounded-md bg-black"
6363
id="export-png-image-box"
6464
>
6565
<span>暂时没有渲染结果,请先点击渲染图片</span>
@@ -106,7 +106,7 @@ export default function ExportPNGPanel() {
106106
</div>
107107
<div>
108108
<p className="text-panel-details-text text-xs">
109-
渲染图片时,会逐个拼接小块,需要等待若干秒才能完成渲染,摄像机缩放比率越大,渲染时间越长,画面分辨率越高
109+
渲染图片时,会逐个拼接小块,需要等待若干秒才能完成渲染,摄像机缩放比率越大,渲染时间越长,画面分辨率越高,目前渲染的图片是透明的
110110
</p>
111111
</div>
112112
{/* 关闭按钮 */}

0 commit comments

Comments
 (0)