@psdk/cpcl
Advanced tools
Comparing version 0.2.52 to 0.2.53
@@ -11,2 +11,4 @@ import { BasicCPCLArg } from "./basic"; | ||
private readonly image; | ||
private readonly reverse; | ||
private readonly threshold; | ||
constructor(options: { | ||
@@ -22,6 +24,14 @@ /** | ||
/** | ||
* enable compress image data, default is true | ||
* enable compress image data, default is false | ||
*/ | ||
compress?: boolean; | ||
/** | ||
* enable reverse image data, default is false | ||
*/ | ||
reverse?: boolean; | ||
/** | ||
* threshold, default is 190 | ||
*/ | ||
threshold?: number; | ||
/** | ||
* image canvas | ||
@@ -28,0 +38,0 @@ */ |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -29,3 +6,3 @@ exports.CImage = void 0; | ||
const frame_father_1 = require("@psdk/frame-father"); | ||
const pako = __importStar(require("pako")); | ||
const pbita_1 = require("@psdk/frame-imageb/src/process/pbit/pbita"); | ||
/** | ||
@@ -36,41 +13,43 @@ * Image | ||
constructor(options) { | ||
var _a, _b, _c; | ||
var _a, _b, _c, _d, _e; | ||
super(); | ||
this.x = (_a = options.x) !== null && _a !== void 0 ? _a : 0; | ||
this.y = (_b = options.y) !== null && _b !== void 0 ? _b : 0; | ||
this.compress = (_c = options.compress) !== null && _c !== void 0 ? _c : true; | ||
this.compress = (_c = options.compress) !== null && _c !== void 0 ? _c : false; | ||
this.reverse = (_d = options.reverse) !== null && _d !== void 0 ? _d : false; | ||
this.threshold = (_e = options.threshold) !== null && _e !== void 0 ? _e : 190; | ||
this.image = options.image; | ||
} | ||
clause() { | ||
const width = this.image.width; | ||
const height = this.image.height; | ||
const processer = new pbita_1.Pbita({ | ||
threshold: this.threshold, | ||
compress: this.compress, | ||
reverse: this.reverse, | ||
}); | ||
const info = processer.process(this.image); | ||
const fimage = info.result.data; | ||
const fbytes = info.result.bytes; | ||
if (fimage == null) { | ||
throw new Error('Wrong image data'); | ||
} | ||
let width = fimage.width; | ||
let height = fimage.height; | ||
const eWidth = Math.floor((width % 8 === 0) ? (width / 8) : (width / 8 + 1)); | ||
const bytes = frame_father_1.ImageKit.processImage(this.image, width, height); | ||
const commander = frame_father_1.Commander.make(); | ||
const ccmd = frame_father_1.CPCLCommand.with(this.header()) | ||
.appendNumber(this.x) | ||
const command = frame_father_1.Commander.make().pushClause(frame_father_1.CPCLCommand.with(this.header()) | ||
.appendNumber(eWidth) | ||
.appendNumber(height) | ||
.appendNumber(this.compress ? this.x / 8 : this.x) | ||
.appendNumber(this.y) | ||
.appendNumber(eWidth) | ||
.appendNumber(height); | ||
if (this.compress) { | ||
const compressed = pako.deflate(bytes); | ||
ccmd.appendNumber(3) | ||
.appendNumber(compressed.length); | ||
commander.pushClause(ccmd.clause(), false) | ||
.pushText(' ', { newline: false }) | ||
.pushBinary(compressed, false); | ||
} | ||
else { | ||
commander.pushClause(ccmd.clause(), false) | ||
.pushText(' ', { newline: false }) | ||
.pushBinary(bytes, false); | ||
} | ||
commander.newline(); | ||
const command = commander.command(); | ||
.appendNumber(this.compress ? fbytes.length : null) | ||
.clause(), false) | ||
.pushText(" ", { newline: false }) | ||
.pushBinary(fbytes, false) | ||
.newline() | ||
.command(); | ||
return frame_father_1.Raw.binary(command.binary()).clause(); | ||
} | ||
header() { | ||
return 'CG'; | ||
return this.compress ? "ZG" : "CG"; | ||
} | ||
} | ||
exports.CImage = CImage; |
@@ -23,2 +23,3 @@ export * from './bar'; | ||
export * from './watermark'; | ||
export * from './sn'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -39,1 +39,2 @@ "use strict"; | ||
__exportStar(require("./watermark"), exports); | ||
__exportStar(require("./sn"), exports); |
@@ -6,8 +6,7 @@ import { CommandClause } from "@psdk/frame-father"; | ||
private readonly height; | ||
private readonly copies; | ||
constructor(options?: { | ||
/** | ||
* 打印区域高度 | ||
*/ | ||
width?: number; | ||
height?: number; | ||
copies?: number; | ||
}); | ||
@@ -14,0 +13,0 @@ clause(): CommandClause; |
@@ -10,9 +10,10 @@ "use strict"; | ||
constructor(options) { | ||
var _a, _b; | ||
var _a, _b, _c; | ||
super(); | ||
this.width = (_a = options === null || options === void 0 ? void 0 : options.width) !== null && _a !== void 0 ? _a : 0; | ||
this.height = (_b = options === null || options === void 0 ? void 0 : options.height) !== null && _b !== void 0 ? _b : 0; | ||
this.copies = (_c = options === null || options === void 0 ? void 0 : options.copies) !== null && _c !== void 0 ? _c : 1; | ||
} | ||
clause() { | ||
super.prepend(new pageheight_1.CPageHeight({ height: this.height })); | ||
super.prepend(new pageheight_1.CPageHeight({ height: this.height, copies: this.copies })); | ||
super.append(new pagewidth_1.CPageWidth({ width: this.width })); | ||
@@ -19,0 +20,0 @@ return frame_father_1.CPCLCommand.with(this.header()) |
@@ -5,2 +5,3 @@ import { CommandClause } from "@psdk/frame-father"; | ||
private height; | ||
private copies; | ||
constructor(options?: { | ||
@@ -11,2 +12,3 @@ /** | ||
height?: number; | ||
copies?: number; | ||
}); | ||
@@ -13,0 +15,0 @@ clause(): CommandClause; |
@@ -8,5 +8,6 @@ "use strict"; | ||
constructor(options) { | ||
var _a; | ||
var _a, _b; | ||
super(); | ||
this.height = (_a = options === null || options === void 0 ? void 0 : options.height) !== null && _a !== void 0 ? _a : 0; | ||
this.copies = (_b = options === null || options === void 0 ? void 0 : options.copies) !== null && _b !== void 0 ? _b : 1; | ||
} | ||
@@ -16,3 +17,3 @@ clause() { | ||
.appendNumber(this.height) | ||
.appendNumber(1) | ||
.appendNumber(this.copies) | ||
.clause(); | ||
@@ -19,0 +20,0 @@ } |
@@ -11,3 +11,4 @@ import { CommandClause } from "@psdk/frame-father"; | ||
private level; | ||
constructor(options?: { | ||
private charset; | ||
constructor(options: { | ||
/** | ||
@@ -30,3 +31,3 @@ * 一维码起始横坐标 | ||
/** | ||
* 条码宽度(2-20) | ||
* 二维码小黑点宽度(2-20) | ||
*/ | ||
@@ -38,2 +39,6 @@ width?: number; | ||
level?: CorrectLevel; | ||
/** | ||
* 编码 | ||
*/ | ||
charset?: string; | ||
}); | ||
@@ -40,0 +45,0 @@ clause(): CommandClause; |
@@ -9,13 +9,14 @@ "use strict"; | ||
constructor(options) { | ||
var _a, _b, _c, _d, _e, _f; | ||
var _a, _b, _c, _d, _e, _f, _g; | ||
super(); | ||
this.x = (_a = options === null || options === void 0 ? void 0 : options.x) !== null && _a !== void 0 ? _a : 0; | ||
this.y = (_b = options === null || options === void 0 ? void 0 : options.y) !== null && _b !== void 0 ? _b : 0; | ||
this.content = (_c = options === null || options === void 0 ? void 0 : options.content) !== null && _c !== void 0 ? _c : ''; | ||
this.codeRotation = (_d = options === null || options === void 0 ? void 0 : options.codeRotation) !== null && _d !== void 0 ? _d : types_1.CodeRotation.ROTATION_0; | ||
this.width = (_e = options === null || options === void 0 ? void 0 : options.width) !== null && _e !== void 0 ? _e : 0; | ||
this.level = (_f = options === null || options === void 0 ? void 0 : options.level) !== null && _f !== void 0 ? _f : types_1.CorrectLevel.H; | ||
this.x = (_a = options.x) !== null && _a !== void 0 ? _a : 0; | ||
this.y = (_b = options.y) !== null && _b !== void 0 ? _b : 0; | ||
this.content = (_c = options.content) !== null && _c !== void 0 ? _c : ''; | ||
this.codeRotation = (_d = options.codeRotation) !== null && _d !== void 0 ? _d : types_1.CodeRotation.ROTATION_0; | ||
this.width = (_e = options.width) !== null && _e !== void 0 ? _e : 0; | ||
this.level = (_f = options.level) !== null && _f !== void 0 ? _f : types_1.CorrectLevel.H; | ||
this.charset = (_g = options.charset) !== null && _g !== void 0 ? _g : 'gbk'; | ||
} | ||
clause() { | ||
return frame_father_1.CPCLCommand.with(this.header()) | ||
return frame_father_1.CPCLCommand.with(this.header(), this.charset) | ||
.appendText("3" + "\n" + this.codeRotation) | ||
@@ -22,0 +23,0 @@ .appendText("QR") |
@@ -8,4 +8,5 @@ import { CommandClause } from "@psdk/frame-father"; | ||
private content; | ||
private font; | ||
private readonly font; | ||
private rotation; | ||
private charset; | ||
constructor(options?: { | ||
@@ -32,2 +33,6 @@ /** | ||
rotation?: Rotation; | ||
/** | ||
* 编码 | ||
*/ | ||
charset?: string; | ||
}); | ||
@@ -34,0 +39,0 @@ clause(): CommandClause; |
@@ -9,3 +9,3 @@ "use strict"; | ||
constructor(options) { | ||
var _a, _b, _c, _d, _e; | ||
var _a, _b, _c, _d, _e, _f; | ||
super(); | ||
@@ -17,2 +17,3 @@ this.x = (_a = options === null || options === void 0 ? void 0 : options.x) !== null && _a !== void 0 ? _a : 0; | ||
this.rotation = (_e = options === null || options === void 0 ? void 0 : options.rotation) !== null && _e !== void 0 ? _e : types_1.Rotation.ROTATION_0; | ||
this.charset = (_f = options === null || options === void 0 ? void 0 : options.charset) !== null && _f !== void 0 ? _f : 'gbk'; | ||
} | ||
@@ -50,3 +51,3 @@ clause() { | ||
} | ||
return frame_father_1.CPCLCommand.with(this.header()) | ||
return frame_father_1.CPCLCommand.with(this.header(), this.charset) | ||
.appendNumber(fontEntity.family) | ||
@@ -53,0 +54,0 @@ .appendNumber(fontEntity.size) |
import { Commander, ConnectedDevice, Lifecycle, PSDK } from '@psdk/frame-father'; | ||
import { CBar } from "../args/bar"; | ||
import { CBox } from "../args/box"; | ||
import { CBold } from "../args/bold"; | ||
import { CFeed } from "../args/feed"; | ||
import { CForm } from "../args/form"; | ||
import { CImage } from "../args/image"; | ||
import { CInverse } from "../args/inverse"; | ||
import { CLine } from "../args/line"; | ||
import { CMag } from "../args/mag"; | ||
import { CPageMode } from "../args/pagemode"; | ||
import { CPage } from "../args/page"; | ||
import { CPrint } from "../args/print"; | ||
import { CQRCode } from "../args/qrcode"; | ||
import { CText } from "../args/text"; | ||
import { CUnderLine } from "../args/underline"; | ||
import { CWaterMark } from "../args/watermark"; | ||
import { CStatus } from "../args/status"; | ||
import { CBar, CBox, CBold, CFeed, CForm, CImage, CInverse, CLine, CMag, CPageMode, CPage, CPrint, CQRCode, CText, CUnderLine, CWaterMark, CStatus, CSN } from "../args"; | ||
export declare abstract class BasicCPCL<T extends BasicCPCL<any>> extends PSDK<T> { | ||
@@ -50,3 +34,4 @@ /** | ||
status(arg: CStatus): T; | ||
sn(arg: CSN): T; | ||
} | ||
//# sourceMappingURL=basic.d.ts.map |
@@ -5,3 +5,3 @@ "use strict"; | ||
const frame_father_1 = require("@psdk/frame-father"); | ||
const print_1 = require("../args/print"); | ||
const args_1 = require("../args"); | ||
const mode_1 = require("../types/mode"); | ||
@@ -54,3 +54,3 @@ class BasicCPCL extends frame_father_1.PSDK { | ||
print(arg) { | ||
return this.push(arg !== null && arg !== void 0 ? arg : new print_1.CPrint({ mode: mode_1.Mode.NORMAL })); | ||
return this.push(arg !== null && arg !== void 0 ? arg : new args_1.CPrint({ mode: mode_1.Mode.NORMAL })); | ||
} | ||
@@ -72,3 +72,6 @@ qrcode(arg) { | ||
} | ||
sn(arg) { | ||
return this.push(arg); | ||
} | ||
} | ||
exports.BasicCPCL = BasicCPCL; |
{ | ||
"name": "@psdk/cpcl", | ||
"version": "0.2.52", | ||
"version": "0.2.53", | ||
"description": "psdk", | ||
@@ -48,3 +48,4 @@ "main": "build/index.js", | ||
"dependencies": { | ||
"@psdk/frame-father": "0.2.52" | ||
"@psdk/frame-father": "0.2.53", | ||
"@psdk/frame-imageb": "0.2.53" | ||
}, | ||
@@ -55,3 +56,3 @@ "files": [ | ||
], | ||
"gitHead": "5208d7ff2b0c566b71705c67b06d2b9c8bb965db" | ||
"gitHead": "ca54986c203c50fbca520339a0bef18805f11a4a" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
72236
112
1748
2
+ Added@psdk/frame-imageb@0.2.53
+ Added@psdk/frame-father@0.2.53(transitive)
+ Added@psdk/frame-imageb@0.2.53(transitive)
- Removed@psdk/frame-father@0.2.52(transitive)
Updated@psdk/frame-father@0.2.53