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"); // 左上