feat: 添加注释

This commit is contained in:
陶林 2024-03-13 10:06:53 +08:00
parent bc169183ba
commit 922d82e27c
4 changed files with 125 additions and 5 deletions

View File

@ -2,7 +2,23 @@
https://www.npmjs.com/package/@taoya7/print-help
示例
PDF文档
https://wiki.taoya.art/s/6712b96b-c67e-4e17-b3f7-ba12e7d146bf
> 注意
200 DPI: 1 mm = 8 dots
300 DPI: 1mm = 12 dots
在公制系统下, 在参数 m 与 “mm” 之间必须要有空格分隔
**示例**
```javascript
import { FONTMUL, FONTTYPE, LabelCommand, ROTATION } from '@/command/Label'
@ -12,7 +28,7 @@ function main() {
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));
console.log(label.getCommandStr(command)); // 转换命令字符串
}
main();
```

View File

@ -1,10 +1,11 @@
{
"name": "@taoya7/print-help",
"version": "1.0.3",
"version": "1.0.4",
"license": "MIT",
"type": "module",
"keywords": [
"佳博打印机"
"佳博打印机",
"打印机"
],
"exports": {
".": {

View File

@ -179,6 +179,7 @@ export class LabelCommand {
}
/**
*
* @param gap (mm)
*/
addGap(gap: number) {
let str = "GAP " + gap + " mm," + 0 + " mm\r\n";
@ -186,6 +187,8 @@ export class LabelCommand {
}
/**
* 使
* GAP 0,0
* @param bline (mm)
*/
addBline(bline: number) {
let str = "BLINE " + bline + " mm," + 0 + " mm\r\n";
@ -193,6 +196,8 @@ export class LabelCommand {
}
/**
*
* @param height (mm)
* @param width (mm)
*/
addSize(width: number, height: number): void {
const str = "SIZE " + width + " mm," + height + " mm\r\n";
@ -202,50 +207,102 @@ export class LabelCommand {
let str: string = `CASHDRAWER ${m},${t1},${t2}\r\n`;
this.addStrToCommand(str);
}
/**
* 使
*
*
* @param offset (mm)
*/
addOffset(offset: number): void {
let str: string = `OFFSET ${offset} mm\r\n`;
this.addStrToCommand(str);
}
/**
*
* @param speed
*/
addSpeed(speed: SPEED): void {
let str: string = `SPEED ${speed / 10}\r\n`;
this.addStrToCommand(str);
}
/**
*
* @param density
*/
addDensity(density: DENSITY): void {
let str: string = `DENSITY ${density}\r\n`;
this.addStrToCommand(str);
}
/**
* EEPROM
* @param direction 0- 1-
* @param mirror
*/
addDirection(direction: DIRECTION, mirror: MIRROR): void {
let str: string = `DIRECTION ${direction}, ${mirror}\r\n`;
this.addStrToCommand(str);
}
/**
*
* @param x dot
* @param y dot
*/
addReference(x: number, y: number): void {
let str: string = `REFERENCE ${x}, ${y}\r\n`;
this.addStrToCommand(str);
}
/**
*
* @param shift 1 inchdot
*/
addShift(shift: number): void {
let str: string = `SHIFT ${shift}\r\n`;
this.addStrToCommand(str);
}
/**
*
* SIZE
*/
addCls(): void {
let str: string = `CLS\r\n`;
this.addStrToCommand(str);
}
/**
* ()
* @param dot dot
*/
addFeed(dot: number): void {
let str: string = `FEED ${dot}\r\n`;
this.addStrToCommand(str);
}
/**
* ()
* @param dot dot
*/
addBackFeed(dot: number): void {
let str: string = `BACKFEED ${dot}\r\n`;
this.addStrToCommand(str);
}
/**
*
*/
addFormFeed(): void {
let str: string = `FORMFEED\r\n`;
this.addStrToCommand(str);
}
/**
* 使
*
*/
addHome(): void {
let str: string = `HOME\r\n`;
this.addStrToCommand(str);
}
/**
*
* @param m
* @param n
*/
addPrint(m: number, n?: number): void {
let str: string = n ? `PRINT ${m}, ${n}\r\n` : `PRINT ${m}\r\n`;
this.addStrToCommand(str);
@ -278,6 +335,13 @@ export class LabelCommand {
let str: string = `SELFTEST\r\n`;
this.addStrToCommand(str);
}
/**
* 线
* @param x 线 X dot
* @param y 线 Y dot
* @param width 线 dot
* @param height 线 dot
*/
addBar(x: number, y: number, width: number, height: number): void {
let str: string = `BAR ${x}, ${y}, ${width}, ${height}\r\n`;
this.addStrToCommand(str);
@ -312,6 +376,10 @@ export class LabelCommand {
'"\r\n';
this.addStrToCommand(str);
}
/**
*
* @param command
*/
addUserCommand(command: string): void {
this.addStrToCommand(command);
}
@ -420,6 +488,15 @@ export class LabelCommand {
let str: string = `~!T\r\n`;
this.addStrToCommand(str);
}
/**
* QRCODE
* @param x QRCODE X
* @param y QRCODE Y
* @param level
* @param cellwidth 1~10
* @param rotation
* @param data
*/
public addQRCode(
x: number,
y: number,
@ -431,10 +508,24 @@ export class LabelCommand {
let str: string = `QRCODE ${x}, ${y}, ${level}, ${cellwidth}, A, ${rotation}, "${data}"\r\n`;
this.addStrToCommand(str);
}
/**
*
* @param x X dot
* @param y Y dot
* @param xwidth dot
* @param yheight dot
*/
addReverse(x: number, y: number, xwidth: number, yheight: number): void {
let str = `REVERSE ${x}, ${y}, ${xwidth}, ${yheight}\r\n`;
this.addStrToCommand(str);
}
/**
*
* @param x X dot
* @param y Y dot
* @param xwidth dot
* @param yheight dot
*/
addErase(x: number, y: number, xwidth: number, yheight: number): void {
let str = `ERASE ${x},${y},${xwidth},${yheight}\r\n`;
this.addStrToCommand(str);
@ -449,6 +540,18 @@ export class LabelCommand {
let str = `DMATRIX ${x},${y},${width},${height},"${content}"\r\n`;
this.addStrToCommand(str);
}
/**
*
* @param x X
* @param y Y
* @param type
* @param height
* @param readable
* @param rotation
* @param narrow
* @param width
* @param content
*/
add1DBarcode(
x: number,
y: number,

View File

@ -9,7 +9,7 @@ import {
} from "@/command/Label";
function main() {
let label = new LabelCommand(50, 30, 0);
let label = new LabelCommand(50, 30, 0); // 长,宽,gap
label.addText(
0,
0,