-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
128 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Command, PrinterLanguage } from "@/commands"; | ||
import { PrintConfig } from "../Printable"; | ||
import LabelField from "./LabelField" | ||
import { Alignment, BarcodeHumanReable, BarcodeType, Rotation } from "@/commands/tspl"; | ||
|
||
export default class BarCode extends LabelField { | ||
private readonly content: string | ||
private readonly x: number | ||
private readonly y: number | ||
private readonly type: BarcodeType | ||
private readonly height: number | ||
private readonly rotation: Rotation | ||
private readonly humanReadable: BarcodeHumanReable | ||
private readonly alignment: Alignment | ||
|
||
constructor(content: string, x: number, y: number, type: BarcodeType, height: number, rotatio: Rotation, humanReadable: BarcodeHumanReable, alignment: Alignment) { | ||
super() | ||
this.content = content | ||
this.x = x | ||
this.y = y | ||
this.type = type | ||
this.height = height | ||
this.rotation = rotatio | ||
this.humanReadable = humanReadable | ||
this.alignment = alignment | ||
} | ||
|
||
async commandForLanguage(language: PrinterLanguage, config?: PrintConfig | undefined): Promise<Command> { | ||
return await this.commandGeneratorFor(language).barCode(this.content, this.x, this.y, this.type, this.height, this.rotation, this.humanReadable, this.alignment) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Command, PrinterLanguage } from "@/commands"; | ||
import { PrintConfig } from "../Printable"; | ||
import LabelField from "./LabelField"; | ||
import ImageUtils, { BitmapLike } from "@/helpers/ImageUtils"; | ||
|
||
export default class Image extends LabelField { | ||
/** | ||
* X coordinate in dots | ||
*/ | ||
private readonly x: number | ||
/** | ||
* Y coordinate in dots | ||
*/ | ||
private readonly y: number | ||
|
||
private readonly image: BitmapLike | ||
|
||
constructor(x: number, y: number, image: BitmapLike) { | ||
super() | ||
this.x = x | ||
this.y = y | ||
this.image = image | ||
} | ||
|
||
async commandForLanguage(language: PrinterLanguage, _config?: PrintConfig | undefined): Promise<Command> { | ||
return await this.commandGeneratorFor(language).image(this.image, this.x, this.y) | ||
} | ||
|
||
/** | ||
* Create an image field for an image | ||
* @param image | ||
* @param x | ||
* @param y | ||
* @param width | ||
* @param height | ||
* @returns | ||
*/ | ||
static async create(image: string, x: number, y: number, width: number, height: number): Promise<Image> { | ||
const bitmap = await ImageUtils.getBWBitmap(image, width, height) | ||
|
||
return new Image(x, y, bitmap) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Command, PrinterLanguage } from "@/commands"; | ||
import { PrintConfig } from "../Printable"; | ||
import LabelField from "./LabelField"; | ||
|
||
export default class QRCode extends LabelField { | ||
private readonly content: string | ||
private readonly x: number | ||
private readonly y: number | ||
private readonly width: number | ||
|
||
constructor(content: string, x: number, y: number, width: number) { | ||
super() | ||
this.content = content | ||
this.x = x | ||
this.y = y | ||
this.width = width | ||
} | ||
|
||
async commandForLanguage(language: PrinterLanguage, config?: PrintConfig | undefined): Promise<Command> { | ||
return await this.commandGeneratorFor(language).qrCode(this.content, this.width, this.x, this.y) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
export * from "./LabelField" | ||
|
||
export { default as Line } from "./Line" | ||
export { default as Text } from "./Text" | ||
export { default as Text } from "./Text" | ||
export { default as BarCode } from "./BarCode" | ||
export { default as Image } from "./Image" | ||
export { default as qrCode } from "./QRCode" |