From 0d90c0b6dd7374c3cf8b11c3d53480d8b9775adc Mon Sep 17 00:00:00 2001 From: onvia <272493431@qq.com> Date: Fri, 22 Dec 2023 17:48:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20png9=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- psd2ui-tools/cmd.bat | 6 ++++++ psd2ui-tools/cmd.sh | 16 ++++++++++++++++ psd2ui-tools/dist/index.js | 4 +++- psd2ui-tools/src/utils/Texture9Utils.ts | 4 +++- 5 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 psd2ui-tools/cmd.bat create mode 100644 psd2ui-tools/cmd.sh diff --git a/package.json b/package.json index faf8800..f1888f7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ccc-tnt-psd2ui", - "version": "1.0.4", + "version": "1.0.5", "description": "", "main": "index.js", "scripts": { diff --git a/psd2ui-tools/cmd.bat b/psd2ui-tools/cmd.bat new file mode 100644 index 0000000..f6c3d77 --- /dev/null +++ b/psd2ui-tools/cmd.bat @@ -0,0 +1,6 @@ +@echo off +echo psd2ui:: Drag and drop a file or folder +set /p var= + +node ./dist/index.js --engine-version v342 --pinyin --input %var% +pause diff --git a/psd2ui-tools/cmd.sh b/psd2ui-tools/cmd.sh new file mode 100644 index 0000000..6f101f6 --- /dev/null +++ b/psd2ui-tools/cmd.sh @@ -0,0 +1,16 @@ + +# node ./dist/index.js +# exec /bin/bash +#!/bin/sh + +#============ get the file name =========== + +echo -e "导出表格数据:拖拽想要处理的文件和文件夹到此" + +read InputDir + +echo "导出数据" + +node dist/index.js --engine-version v342 --pinyin --input "${InputDir}" + +exec /bin/bash \ No newline at end of file diff --git a/psd2ui-tools/dist/index.js b/psd2ui-tools/dist/index.js index 126a7d3..0be8a05 100644 --- a/psd2ui-tools/dist/index.js +++ b/psd2ui-tools/dist/index.js @@ -1457,7 +1457,9 @@ console.log(`Texture9Utils-> 设置的九宫格 bottom, top 数据不合理,请重新设置`); return _canvas; } - let newCanvas = canvas__default["default"].createCanvas(Math.min(cw, border.l + border.r + space) || cw, Math.min(ch, border.b + border.t + space) || ch); + let imgW = border.l + border.r == 0 ? cw : Math.min(cw, border.l + border.r + space); + let imgH = border.b + border.t == 0 ? ch : Math.min(ch, border.b + border.t + space); + let newCanvas = canvas__default["default"].createCanvas(imgW, imgH); let ctx = newCanvas.getContext("2d"); // 左上 ctx.drawImage(_canvas, 0, 0, left + space, top + space, 0, 0, left + space, top + space); diff --git a/psd2ui-tools/src/utils/Texture9Utils.ts b/psd2ui-tools/src/utils/Texture9Utils.ts index be2fbe9..6444d26 100644 --- a/psd2ui-tools/src/utils/Texture9Utils.ts +++ b/psd2ui-tools/src/utils/Texture9Utils.ts @@ -40,7 +40,9 @@ export class Texture9Utils { return _canvas; } - let newCanvas = canvas.createCanvas(Math.min(cw, border.l + border.r + space) || cw, Math.min(ch, border.b + border.t + space) || ch); + let imgW = border.l + border.r == 0 ? cw : Math.min(cw, border.l + border.r + space); + let imgH = border.b + border.t == 0 ? ch : Math.min(ch, border.b + border.t + space); + let newCanvas = canvas.createCanvas(imgW, imgH); let ctx = newCanvas.getContext("2d"); // 左上