feat: init
This commit is contained in:
parent
66bca689d6
commit
65613ce895
@ -164,8 +164,8 @@ export class LabelCommand {
|
||||
command: number[] = [];
|
||||
constructor(width: number, height: number, gap: number) {
|
||||
this.command = new Array();
|
||||
this.addSize(width, height);
|
||||
this.addGap(gap);
|
||||
// this.addSize(width, height);
|
||||
// this.addGap(gap);
|
||||
}
|
||||
public clrCommand() {
|
||||
this.command = [];
|
||||
@ -271,8 +271,11 @@ export class LabelCommand {
|
||||
let str: string = `BAR ${x}, ${y}, ${width}, ${height}\r\n`;
|
||||
this.addStrToCommand(str);
|
||||
}
|
||||
/***
|
||||
* 添加文本
|
||||
*/
|
||||
addText(x: number, y: number, font: FONTTYPE, rotation: ROTATION, Xscal: FONTMUL, Yscal: FONTMUL, text: string): void {
|
||||
let str: string = `TEXT ${x}, ${y}, "${font}", ${rotation}, ${Xscal}, ${Yscal}, "${text}"\r\n`;
|
||||
const str = "TEXT " + x + "," + y + ",\"" + font + "\"," + rotation + "," + Xscal + "," + Yscal + ",\"" + text + "\"\r\n";
|
||||
this.addStrToCommand(str);
|
||||
}
|
||||
addUserCommand(command: string): void {
|
||||
@ -365,7 +368,14 @@ export class LabelCommand {
|
||||
this.addStrToCommand(str);
|
||||
}
|
||||
getCommand() {
|
||||
return this.command.join(',');
|
||||
return this.command;
|
||||
}
|
||||
getCommandStr(command: number[]) {
|
||||
let str = "";
|
||||
for (let i = 0; i < command.length; i++) {
|
||||
str += String.fromCharCode(command[i]);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
addQueryPrinterType(): void {
|
||||
let str: string = `~!T\r\n`;
|
||||
|
@ -1,9 +1,12 @@
|
||||
export * from './command'
|
||||
|
||||
import { LabelCommand } from '@/command/Label'
|
||||
import { FONTMUL, FONTTYPE, LabelCommand, ROTATION } from '@/command/Label'
|
||||
|
||||
function main() {
|
||||
let label = new LabelCommand(50, 30, 0);
|
||||
console.log(label.getCommand());
|
||||
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();
|
Loading…
Reference in New Issue
Block a user