@nuintun/qrcode
Advanced tools
Comparing version 3.1.0 to 3.1.1
@@ -131,11 +131,2 @@ 'use strict'; | ||
}; | ||
GIFImage.prototype.writeWord = function (output, i) { | ||
output.writeByte(i & 0xff); | ||
output.writeByte((i >>> 8) & 0xff); | ||
}; | ||
GIFImage.prototype.writeBytes = function (output, bytes, off, length) { | ||
for (var i = 0; i < length; i++) { | ||
output.writeByte(bytes[i + off]); | ||
} | ||
}; | ||
GIFImage.prototype.setPixel = function (x, y, pixel) { | ||
@@ -167,4 +158,4 @@ var _a = this, width = _a.width, height = _a.height; | ||
// Screen Descriptor | ||
this.writeWord(output, width); | ||
this.writeWord(output, height); | ||
output.writeInt16(width); | ||
output.writeInt16(height); | ||
output.writeByte(0x80); // 2bit | ||
@@ -184,6 +175,6 @@ output.writeByte(0); | ||
output.writeByte(0x2c); // , | ||
this.writeWord(output, 0); | ||
this.writeWord(output, 0); | ||
this.writeWord(output, width); | ||
this.writeWord(output, height); | ||
output.writeInt16(0); | ||
output.writeInt16(0); | ||
output.writeInt16(width); | ||
output.writeInt16(height); | ||
output.writeByte(0); | ||
@@ -199,3 +190,3 @@ // Local Color Map | ||
output.writeByte(255); | ||
this.writeBytes(output, raster, offset, 255); | ||
output.writeBytes(raster, offset, 255); | ||
offset += 255; | ||
@@ -205,3 +196,3 @@ } | ||
output.writeByte(length); | ||
this.writeBytes(output, raster, offset, length); | ||
output.writeBytes(raster, offset, length); | ||
output.writeByte(0x00); | ||
@@ -208,0 +199,0 @@ // GIF Terminator |
@@ -21,2 +21,5 @@ 'use strict'; | ||
}; | ||
ByteArrayOutputStream.prototype.writeInt16 = function (byte) { | ||
this.bytes.push(byte, byte >>> 8); | ||
}; | ||
ByteArrayOutputStream.prototype.toByteArray = function () { | ||
@@ -23,0 +26,0 @@ return this.bytes; |
@@ -11,6 +11,7 @@ 'use strict'; | ||
} | ||
OutputStream.prototype.writeBytes = function (bytes) { | ||
for (var _i = 0, bytes_1 = bytes; _i < bytes_1.length; _i++) { | ||
var byte = bytes_1[_i]; | ||
this.writeByte(byte); | ||
OutputStream.prototype.writeBytes = function (bytes, offset, length) { | ||
if (offset === void 0) { offset = 0; } | ||
if (length === void 0) { length = bytes.length; } | ||
for (var i = 0; i < length; i++) { | ||
this.writeByte(bytes[i + offset]); | ||
} | ||
@@ -17,0 +18,0 @@ }; |
@@ -481,11 +481,11 @@ 'use strict'; | ||
var size = moduleSize * matrixSize + margin * 2; | ||
var min = margin; | ||
var max = size - margin; | ||
var gif = new GIFImage.GIFImage(size, size); | ||
for (var y = 0; y < size; y++) { | ||
for (var x = 0; x < size; x++) { | ||
if (margin <= x && | ||
x < size - margin && | ||
margin <= y && | ||
y < size - margin && | ||
this.isDark(((y - margin) / moduleSize) >> 0, ((x - margin) / moduleSize) >> 0)) { | ||
gif.setPixel(x, y, 0); | ||
if (min <= x && x < max && min <= y && y < max) { | ||
var col = ((x - min) / moduleSize) >> 0; | ||
var row = ((y - min) / moduleSize) >> 0; | ||
gif.setPixel(x, y, this.isDark(row, col) ? 0 : 1); | ||
} | ||
@@ -492,0 +492,0 @@ else { |
@@ -129,11 +129,2 @@ import { ByteArrayOutputStream } from '../io/ByteArrayOutputStream.js'; | ||
}; | ||
GIFImage.prototype.writeWord = function (output, i) { | ||
output.writeByte(i & 0xff); | ||
output.writeByte((i >>> 8) & 0xff); | ||
}; | ||
GIFImage.prototype.writeBytes = function (output, bytes, off, length) { | ||
for (var i = 0; i < length; i++) { | ||
output.writeByte(bytes[i + off]); | ||
} | ||
}; | ||
GIFImage.prototype.setPixel = function (x, y, pixel) { | ||
@@ -165,4 +156,4 @@ var _a = this, width = _a.width, height = _a.height; | ||
// Screen Descriptor | ||
this.writeWord(output, width); | ||
this.writeWord(output, height); | ||
output.writeInt16(width); | ||
output.writeInt16(height); | ||
output.writeByte(0x80); // 2bit | ||
@@ -182,6 +173,6 @@ output.writeByte(0); | ||
output.writeByte(0x2c); // , | ||
this.writeWord(output, 0); | ||
this.writeWord(output, 0); | ||
this.writeWord(output, width); | ||
this.writeWord(output, height); | ||
output.writeInt16(0); | ||
output.writeInt16(0); | ||
output.writeInt16(width); | ||
output.writeInt16(height); | ||
output.writeByte(0); | ||
@@ -197,3 +188,3 @@ // Local Color Map | ||
output.writeByte(255); | ||
this.writeBytes(output, raster, offset, 255); | ||
output.writeBytes(raster, offset, 255); | ||
offset += 255; | ||
@@ -203,3 +194,3 @@ } | ||
output.writeByte(length); | ||
this.writeBytes(output, raster, offset, length); | ||
output.writeBytes(raster, offset, length); | ||
output.writeByte(0x00); | ||
@@ -206,0 +197,0 @@ // GIF Terminator |
@@ -19,2 +19,5 @@ import { __extends } from 'tslib'; | ||
}; | ||
ByteArrayOutputStream.prototype.writeInt16 = function (byte) { | ||
this.bytes.push(byte, byte >>> 8); | ||
}; | ||
ByteArrayOutputStream.prototype.toByteArray = function () { | ||
@@ -21,0 +24,0 @@ return this.bytes; |
@@ -9,6 +9,7 @@ /** | ||
} | ||
OutputStream.prototype.writeBytes = function (bytes) { | ||
for (var _i = 0, bytes_1 = bytes; _i < bytes_1.length; _i++) { | ||
var byte = bytes_1[_i]; | ||
this.writeByte(byte); | ||
OutputStream.prototype.writeBytes = function (bytes, offset, length) { | ||
if (offset === void 0) { offset = 0; } | ||
if (length === void 0) { length = bytes.length; } | ||
for (var i = 0; i < length; i++) { | ||
this.writeByte(bytes[i + offset]); | ||
} | ||
@@ -15,0 +16,0 @@ }; |
@@ -479,11 +479,11 @@ import { QRByte } from './QRByte.js'; | ||
var size = moduleSize * matrixSize + margin * 2; | ||
var min = margin; | ||
var max = size - margin; | ||
var gif = new GIFImage(size, size); | ||
for (var y = 0; y < size; y++) { | ||
for (var x = 0; x < size; x++) { | ||
if (margin <= x && | ||
x < size - margin && | ||
margin <= y && | ||
y < size - margin && | ||
this.isDark(((y - margin) / moduleSize) >> 0, ((x - margin) / moduleSize) >> 0)) { | ||
gif.setPixel(x, y, 0); | ||
if (min <= x && x < max && min <= y && y < max) { | ||
var col = ((x - min) / moduleSize) >> 0; | ||
var row = ((y - min) / moduleSize) >> 0; | ||
gif.setPixel(x, y, this.isDark(row, col) ? 0 : 1); | ||
} | ||
@@ -490,0 +490,0 @@ else { |
{ | ||
"name": "@nuintun/qrcode", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"description": "A pure JavaScript QRCode encode and decode library.", | ||
@@ -42,5 +42,5 @@ "main": "cjs/index.js", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^2.64.0", | ||
"rollup": "^2.65.0", | ||
"prettier": "^2.5.1", | ||
"typescript": "^4.5.4", | ||
"typescript": "^4.5.5", | ||
"magic-string": "^0.25.7", | ||
@@ -47,0 +47,0 @@ "@types/node": "^17.0.10", |
@@ -6,3 +6,3 @@ /** | ||
*/ | ||
import { OutputStream } from '../io/OutputStream'; | ||
import { ByteArrayOutputStream } from '../io/ByteArrayOutputStream'; | ||
export declare class GIFImage { | ||
@@ -14,8 +14,6 @@ private width; | ||
private getLZWRaster; | ||
private writeWord; | ||
private writeBytes; | ||
setPixel(x: number, y: number, pixel: number): void; | ||
getPixel(x: number, y: number): number; | ||
write(output: OutputStream): void; | ||
write(output: ByteArrayOutputStream): void; | ||
toDataURL(): string; | ||
} |
@@ -10,3 +10,4 @@ /** | ||
writeByte(byte: number): void; | ||
writeInt16(byte: number): void; | ||
toByteArray(): number[]; | ||
} |
@@ -8,5 +8,5 @@ /** | ||
abstract writeByte(byte: number): void; | ||
writeBytes(bytes: number[]): void; | ||
writeBytes(bytes: number[], offset?: number, length?: number): void; | ||
flush(): void; | ||
close(): void; | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
427668
11099