diff --git a/README.md b/README.md index f5d9b9d..ebdcf7a 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,18 @@ -https://www.npmjs.com/package/@taoya7/print-help \ No newline at end of file +https://www.npmjs.com/package/@taoya7/print-help + +示例 + +```javascript +import { FONTMUL, FONTTYPE, LabelCommand, ROTATION } from '@/command/Label' + +function main() { + let label = new LabelCommand(50, 30, 0); + label.addText(0, 0, FONTTYPE.FONT_1, ROTATION.ROTATION_0, FONTMUL.MUL_1, FONTMUL.MUL_1, 'Hello World'); + var command = label.getCommand(); + console.log(command);// 获取字节码 + console.log(label.getCommandStr(command)); +} +main(); +``` \ No newline at end of file diff --git a/package.json b/package.json index 94ea962..7f357fb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@taoya7/print-help", - "version": "1.0.0", + "version": "1.0.1", "license": "MIT", "type": "module", "keywords": [ diff --git a/src/command/Label.ts b/src/command/Label.ts index da7926c..d572374 100644 --- a/src/command/Label.ts +++ b/src/command/Label.ts @@ -367,9 +367,15 @@ export class LabelCommand { let str: string = `SET CUTTER ${enable}\r\n`; this.addStrToCommand(str); } + /** + * 获取命令 + */ getCommand() { return this.command; } + /** + * 获取命令字符串 + */ getCommandStr(command: number[]) { let str = ""; for (let i = 0; i < command.length; i++) {