gb-image-decoder 0.1.3 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +27 -23
- package/dist/index.d.cts +8 -3
- package/dist/index.d.mts +8 -3
- package/dist/index.d.ts +8 -3
- package/dist/index.mjs +27 -23
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -191,7 +191,7 @@ var __publicField$1 = (obj, key, value) => {
|
|
|
191
191
|
return value;
|
|
192
192
|
};
|
|
193
193
|
class Decoder {
|
|
194
|
-
constructor() {
|
|
194
|
+
constructor(options) {
|
|
195
195
|
__publicField$1(this, "canvas");
|
|
196
196
|
__publicField$1(this, "tiles");
|
|
197
197
|
__publicField$1(this, "colors");
|
|
@@ -199,6 +199,7 @@ class Decoder {
|
|
|
199
199
|
__publicField$1(this, "lockFrame");
|
|
200
200
|
__publicField$1(this, "invertPalette");
|
|
201
201
|
__publicField$1(this, "colorData");
|
|
202
|
+
__publicField$1(this, "tilesPerLine");
|
|
202
203
|
this.canvas = null;
|
|
203
204
|
this.tiles = [];
|
|
204
205
|
this.colors = [];
|
|
@@ -206,6 +207,7 @@ class Decoder {
|
|
|
206
207
|
this.lockFrame = false;
|
|
207
208
|
this.invertPalette = false;
|
|
208
209
|
this.colorData = [...BW_PALETTE];
|
|
210
|
+
this.tilesPerLine = options?.tilesPerLine || TILES_PER_LINE;
|
|
209
211
|
}
|
|
210
212
|
update({
|
|
211
213
|
canvas = null,
|
|
@@ -231,7 +233,7 @@ class Decoder {
|
|
|
231
233
|
}
|
|
232
234
|
if (this.canvas.height !== newHeight || !this.rawImageData?.length) {
|
|
233
235
|
this.canvas.height = newHeight;
|
|
234
|
-
const newRawImageData = new Uint8ClampedArray(
|
|
236
|
+
const newRawImageData = new Uint8ClampedArray(this.tilesPerLine * TILE_PIXEL_WIDTH * newHeight * 4);
|
|
235
237
|
this.rawImageData?.forEach((value, index) => {
|
|
236
238
|
newRawImageData[index] = value;
|
|
237
239
|
});
|
|
@@ -247,7 +249,7 @@ class Decoder {
|
|
|
247
249
|
return;
|
|
248
250
|
}
|
|
249
251
|
const context = this.canvas.getContext("2d");
|
|
250
|
-
const imageData = new ImageData(this.rawImageData,
|
|
252
|
+
const imageData = new ImageData(this.rawImageData, this.tilesPerLine * TILE_PIXEL_WIDTH, newHeight);
|
|
251
253
|
context?.putImageData(imageData, 0, 0);
|
|
252
254
|
}
|
|
253
255
|
getScaledCanvas(scaleFactor, handleExportFrame = ExportFrameMode.FRAMEMODE_KEEP) {
|
|
@@ -256,7 +258,7 @@ class Decoder {
|
|
|
256
258
|
initialHeight,
|
|
257
259
|
initialWidth,
|
|
258
260
|
tilesPerLine
|
|
259
|
-
} =
|
|
261
|
+
} = this.getScaledCanvasSize(handleFrameMode, this.getHeight());
|
|
260
262
|
const canvas = document.createElement("canvas");
|
|
261
263
|
const context = canvas.getContext("2d");
|
|
262
264
|
if (!context) {
|
|
@@ -269,27 +271,27 @@ class Decoder {
|
|
|
269
271
|
});
|
|
270
272
|
return canvas;
|
|
271
273
|
}
|
|
272
|
-
|
|
274
|
+
getScaledCanvasSize(handleExportFrame, height) {
|
|
273
275
|
const FRAME_TILES = 4;
|
|
274
276
|
switch (handleExportFrame) {
|
|
275
277
|
case ExportFrameMode.FRAMEMODE_KEEP:
|
|
276
278
|
return {
|
|
277
279
|
initialHeight: height,
|
|
278
|
-
initialWidth:
|
|
279
|
-
tilesPerLine:
|
|
280
|
+
initialWidth: this.tilesPerLine * TILE_PIXEL_WIDTH,
|
|
281
|
+
tilesPerLine: this.tilesPerLine
|
|
280
282
|
};
|
|
281
283
|
case ExportFrameMode.FRAMEMODE_CROP:
|
|
282
284
|
return {
|
|
283
285
|
initialHeight: height - TILE_PIXEL_HEIGHT * FRAME_TILES,
|
|
284
|
-
initialWidth:
|
|
285
|
-
tilesPerLine:
|
|
286
|
+
initialWidth: this.tilesPerLine * TILE_PIXEL_WIDTH - TILE_PIXEL_WIDTH * FRAME_TILES,
|
|
287
|
+
tilesPerLine: this.tilesPerLine - FRAME_TILES
|
|
286
288
|
};
|
|
287
289
|
case ExportFrameMode.FRAMEMODE_SQUARE_BLACK:
|
|
288
290
|
case ExportFrameMode.FRAMEMODE_SQUARE_WHITE:
|
|
289
291
|
return {
|
|
290
292
|
initialHeight: height + 2 * TILE_PIXEL_HEIGHT,
|
|
291
|
-
initialWidth:
|
|
292
|
-
tilesPerLine:
|
|
293
|
+
initialWidth: this.tilesPerLine * TILE_PIXEL_WIDTH,
|
|
294
|
+
tilesPerLine: this.tilesPerLine
|
|
293
295
|
};
|
|
294
296
|
default:
|
|
295
297
|
throw new Error(`unknown export mode ${handleExportFrame}`);
|
|
@@ -371,13 +373,13 @@ class Decoder {
|
|
|
371
373
|
if (!this.rawImageData) {
|
|
372
374
|
return;
|
|
373
375
|
}
|
|
374
|
-
const tileXOffset = index %
|
|
375
|
-
const tileYOffset = Math.floor(index /
|
|
376
|
+
const tileXOffset = index % this.tilesPerLine;
|
|
377
|
+
const tileYOffset = Math.floor(index / this.tilesPerLine);
|
|
376
378
|
const pixelXOffset = TILE_PIXEL_WIDTH * tileXOffset;
|
|
377
379
|
const pixelYOffset = TILE_PIXEL_HEIGHT * tileYOffset;
|
|
378
380
|
for (let x = 0; x < TILE_PIXEL_WIDTH; x += 1) {
|
|
379
381
|
for (let y = 0; y < TILE_PIXEL_HEIGHT; y += 1) {
|
|
380
|
-
const rawIndex = (pixelXOffset + x + (pixelYOffset + y) *
|
|
382
|
+
const rawIndex = (pixelXOffset + x + (pixelYOffset + y) * this.tilesPerLine * TILE_PIXEL_WIDTH) * 4;
|
|
381
383
|
const color = getRGBValue({
|
|
382
384
|
pixels,
|
|
383
385
|
index: y * TILE_PIXEL_WIDTH + x,
|
|
@@ -421,7 +423,7 @@ class Decoder {
|
|
|
421
423
|
}
|
|
422
424
|
}
|
|
423
425
|
getHeight() {
|
|
424
|
-
return TILE_PIXEL_HEIGHT * Math.ceil(this.tiles.length /
|
|
426
|
+
return TILE_PIXEL_HEIGHT * Math.ceil(this.tiles.length / this.tilesPerLine);
|
|
425
427
|
}
|
|
426
428
|
}
|
|
427
429
|
|
|
@@ -439,9 +441,9 @@ var __publicField = (obj, key, value) => {
|
|
|
439
441
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
440
442
|
return value;
|
|
441
443
|
};
|
|
442
|
-
const createChannel = (key) => {
|
|
444
|
+
const createChannel = (key, tilesPerLine) => {
|
|
443
445
|
const canvas = document.createElement("canvas");
|
|
444
|
-
const decoder = new Decoder();
|
|
446
|
+
const decoder = new Decoder({ tilesPerLine });
|
|
445
447
|
decoder.update({
|
|
446
448
|
canvas,
|
|
447
449
|
tiles: [],
|
|
@@ -456,19 +458,21 @@ const createChannel = (key) => {
|
|
|
456
458
|
};
|
|
457
459
|
};
|
|
458
460
|
class RGBNDecoder {
|
|
459
|
-
constructor() {
|
|
461
|
+
constructor(options) {
|
|
460
462
|
__publicField(this, "canvas");
|
|
461
463
|
__publicField(this, "palette");
|
|
462
464
|
__publicField(this, "lockFrame");
|
|
463
465
|
__publicField(this, "channels");
|
|
466
|
+
__publicField(this, "tilesPerLine");
|
|
464
467
|
this.canvas = null;
|
|
465
468
|
this.palette = defaultPalette;
|
|
466
469
|
this.lockFrame = false;
|
|
470
|
+
this.tilesPerLine = options?.tilesPerLine || TILES_PER_LINE;
|
|
467
471
|
this.channels = {
|
|
468
|
-
r: createChannel(ChannelKey.R),
|
|
469
|
-
g: createChannel(ChannelKey.G),
|
|
470
|
-
b: createChannel(ChannelKey.B),
|
|
471
|
-
n: createChannel(ChannelKey.N)
|
|
472
|
+
r: createChannel(ChannelKey.R, this.tilesPerLine),
|
|
473
|
+
g: createChannel(ChannelKey.G, this.tilesPerLine),
|
|
474
|
+
b: createChannel(ChannelKey.B, this.tilesPerLine),
|
|
475
|
+
n: createChannel(ChannelKey.N, this.tilesPerLine)
|
|
472
476
|
};
|
|
473
477
|
}
|
|
474
478
|
update({
|
|
@@ -600,7 +604,7 @@ class RGBNDecoder {
|
|
|
600
604
|
}, 0);
|
|
601
605
|
}
|
|
602
606
|
getHeight() {
|
|
603
|
-
return TILE_PIXEL_HEIGHT * Math.ceil(this.maxTiles() /
|
|
607
|
+
return TILE_PIXEL_HEIGHT * Math.ceil(this.maxTiles() / this.tilesPerLine);
|
|
604
608
|
}
|
|
605
609
|
}
|
|
606
610
|
|
package/dist/index.d.cts
CHANGED
|
@@ -61,6 +61,9 @@ interface RGBNPalette {
|
|
|
61
61
|
n?: number[];
|
|
62
62
|
blend?: BlendMode;
|
|
63
63
|
}
|
|
64
|
+
interface DecoderOptions {
|
|
65
|
+
tilesPerLine?: number;
|
|
66
|
+
}
|
|
64
67
|
|
|
65
68
|
declare class Decoder {
|
|
66
69
|
private canvas;
|
|
@@ -70,7 +73,8 @@ declare class Decoder {
|
|
|
70
73
|
private lockFrame;
|
|
71
74
|
private invertPalette;
|
|
72
75
|
private colorData;
|
|
73
|
-
|
|
76
|
+
private tilesPerLine;
|
|
77
|
+
constructor(options?: DecoderOptions);
|
|
74
78
|
update({ canvas, tiles, palette, lockFrame, invertPalette, }: {
|
|
75
79
|
canvas: HTMLCanvasElement | null;
|
|
76
80
|
tiles: string[];
|
|
@@ -80,7 +84,7 @@ declare class Decoder {
|
|
|
80
84
|
}): void;
|
|
81
85
|
private updateCanvas;
|
|
82
86
|
getScaledCanvas(scaleFactor: number, handleExportFrame?: ExportFrameMode): HTMLCanvasElement;
|
|
83
|
-
|
|
87
|
+
private getScaledCanvasSize;
|
|
84
88
|
private getExportTiles;
|
|
85
89
|
private setCanvas;
|
|
86
90
|
private setPalette;
|
|
@@ -97,7 +101,8 @@ declare class RGBNDecoder {
|
|
|
97
101
|
private palette;
|
|
98
102
|
private lockFrame;
|
|
99
103
|
private channels;
|
|
100
|
-
|
|
104
|
+
private tilesPerLine;
|
|
105
|
+
constructor(options: DecoderOptions);
|
|
101
106
|
update({ canvas, tiles, palette, lockFrame, }: {
|
|
102
107
|
canvas: HTMLCanvasElement | null;
|
|
103
108
|
tiles: RGBNTiles;
|
package/dist/index.d.mts
CHANGED
|
@@ -61,6 +61,9 @@ interface RGBNPalette {
|
|
|
61
61
|
n?: number[];
|
|
62
62
|
blend?: BlendMode;
|
|
63
63
|
}
|
|
64
|
+
interface DecoderOptions {
|
|
65
|
+
tilesPerLine?: number;
|
|
66
|
+
}
|
|
64
67
|
|
|
65
68
|
declare class Decoder {
|
|
66
69
|
private canvas;
|
|
@@ -70,7 +73,8 @@ declare class Decoder {
|
|
|
70
73
|
private lockFrame;
|
|
71
74
|
private invertPalette;
|
|
72
75
|
private colorData;
|
|
73
|
-
|
|
76
|
+
private tilesPerLine;
|
|
77
|
+
constructor(options?: DecoderOptions);
|
|
74
78
|
update({ canvas, tiles, palette, lockFrame, invertPalette, }: {
|
|
75
79
|
canvas: HTMLCanvasElement | null;
|
|
76
80
|
tiles: string[];
|
|
@@ -80,7 +84,7 @@ declare class Decoder {
|
|
|
80
84
|
}): void;
|
|
81
85
|
private updateCanvas;
|
|
82
86
|
getScaledCanvas(scaleFactor: number, handleExportFrame?: ExportFrameMode): HTMLCanvasElement;
|
|
83
|
-
|
|
87
|
+
private getScaledCanvasSize;
|
|
84
88
|
private getExportTiles;
|
|
85
89
|
private setCanvas;
|
|
86
90
|
private setPalette;
|
|
@@ -97,7 +101,8 @@ declare class RGBNDecoder {
|
|
|
97
101
|
private palette;
|
|
98
102
|
private lockFrame;
|
|
99
103
|
private channels;
|
|
100
|
-
|
|
104
|
+
private tilesPerLine;
|
|
105
|
+
constructor(options: DecoderOptions);
|
|
101
106
|
update({ canvas, tiles, palette, lockFrame, }: {
|
|
102
107
|
canvas: HTMLCanvasElement | null;
|
|
103
108
|
tiles: RGBNTiles;
|
package/dist/index.d.ts
CHANGED
|
@@ -61,6 +61,9 @@ interface RGBNPalette {
|
|
|
61
61
|
n?: number[];
|
|
62
62
|
blend?: BlendMode;
|
|
63
63
|
}
|
|
64
|
+
interface DecoderOptions {
|
|
65
|
+
tilesPerLine?: number;
|
|
66
|
+
}
|
|
64
67
|
|
|
65
68
|
declare class Decoder {
|
|
66
69
|
private canvas;
|
|
@@ -70,7 +73,8 @@ declare class Decoder {
|
|
|
70
73
|
private lockFrame;
|
|
71
74
|
private invertPalette;
|
|
72
75
|
private colorData;
|
|
73
|
-
|
|
76
|
+
private tilesPerLine;
|
|
77
|
+
constructor(options?: DecoderOptions);
|
|
74
78
|
update({ canvas, tiles, palette, lockFrame, invertPalette, }: {
|
|
75
79
|
canvas: HTMLCanvasElement | null;
|
|
76
80
|
tiles: string[];
|
|
@@ -80,7 +84,7 @@ declare class Decoder {
|
|
|
80
84
|
}): void;
|
|
81
85
|
private updateCanvas;
|
|
82
86
|
getScaledCanvas(scaleFactor: number, handleExportFrame?: ExportFrameMode): HTMLCanvasElement;
|
|
83
|
-
|
|
87
|
+
private getScaledCanvasSize;
|
|
84
88
|
private getExportTiles;
|
|
85
89
|
private setCanvas;
|
|
86
90
|
private setPalette;
|
|
@@ -97,7 +101,8 @@ declare class RGBNDecoder {
|
|
|
97
101
|
private palette;
|
|
98
102
|
private lockFrame;
|
|
99
103
|
private channels;
|
|
100
|
-
|
|
104
|
+
private tilesPerLine;
|
|
105
|
+
constructor(options: DecoderOptions);
|
|
101
106
|
update({ canvas, tiles, palette, lockFrame, }: {
|
|
102
107
|
canvas: HTMLCanvasElement | null;
|
|
103
108
|
tiles: RGBNTiles;
|
package/dist/index.mjs
CHANGED
|
@@ -189,7 +189,7 @@ var __publicField$1 = (obj, key, value) => {
|
|
|
189
189
|
return value;
|
|
190
190
|
};
|
|
191
191
|
class Decoder {
|
|
192
|
-
constructor() {
|
|
192
|
+
constructor(options) {
|
|
193
193
|
__publicField$1(this, "canvas");
|
|
194
194
|
__publicField$1(this, "tiles");
|
|
195
195
|
__publicField$1(this, "colors");
|
|
@@ -197,6 +197,7 @@ class Decoder {
|
|
|
197
197
|
__publicField$1(this, "lockFrame");
|
|
198
198
|
__publicField$1(this, "invertPalette");
|
|
199
199
|
__publicField$1(this, "colorData");
|
|
200
|
+
__publicField$1(this, "tilesPerLine");
|
|
200
201
|
this.canvas = null;
|
|
201
202
|
this.tiles = [];
|
|
202
203
|
this.colors = [];
|
|
@@ -204,6 +205,7 @@ class Decoder {
|
|
|
204
205
|
this.lockFrame = false;
|
|
205
206
|
this.invertPalette = false;
|
|
206
207
|
this.colorData = [...BW_PALETTE];
|
|
208
|
+
this.tilesPerLine = options?.tilesPerLine || TILES_PER_LINE;
|
|
207
209
|
}
|
|
208
210
|
update({
|
|
209
211
|
canvas = null,
|
|
@@ -229,7 +231,7 @@ class Decoder {
|
|
|
229
231
|
}
|
|
230
232
|
if (this.canvas.height !== newHeight || !this.rawImageData?.length) {
|
|
231
233
|
this.canvas.height = newHeight;
|
|
232
|
-
const newRawImageData = new Uint8ClampedArray(
|
|
234
|
+
const newRawImageData = new Uint8ClampedArray(this.tilesPerLine * TILE_PIXEL_WIDTH * newHeight * 4);
|
|
233
235
|
this.rawImageData?.forEach((value, index) => {
|
|
234
236
|
newRawImageData[index] = value;
|
|
235
237
|
});
|
|
@@ -245,7 +247,7 @@ class Decoder {
|
|
|
245
247
|
return;
|
|
246
248
|
}
|
|
247
249
|
const context = this.canvas.getContext("2d");
|
|
248
|
-
const imageData = new ImageData(this.rawImageData,
|
|
250
|
+
const imageData = new ImageData(this.rawImageData, this.tilesPerLine * TILE_PIXEL_WIDTH, newHeight);
|
|
249
251
|
context?.putImageData(imageData, 0, 0);
|
|
250
252
|
}
|
|
251
253
|
getScaledCanvas(scaleFactor, handleExportFrame = ExportFrameMode.FRAMEMODE_KEEP) {
|
|
@@ -254,7 +256,7 @@ class Decoder {
|
|
|
254
256
|
initialHeight,
|
|
255
257
|
initialWidth,
|
|
256
258
|
tilesPerLine
|
|
257
|
-
} =
|
|
259
|
+
} = this.getScaledCanvasSize(handleFrameMode, this.getHeight());
|
|
258
260
|
const canvas = document.createElement("canvas");
|
|
259
261
|
const context = canvas.getContext("2d");
|
|
260
262
|
if (!context) {
|
|
@@ -267,27 +269,27 @@ class Decoder {
|
|
|
267
269
|
});
|
|
268
270
|
return canvas;
|
|
269
271
|
}
|
|
270
|
-
|
|
272
|
+
getScaledCanvasSize(handleExportFrame, height) {
|
|
271
273
|
const FRAME_TILES = 4;
|
|
272
274
|
switch (handleExportFrame) {
|
|
273
275
|
case ExportFrameMode.FRAMEMODE_KEEP:
|
|
274
276
|
return {
|
|
275
277
|
initialHeight: height,
|
|
276
|
-
initialWidth:
|
|
277
|
-
tilesPerLine:
|
|
278
|
+
initialWidth: this.tilesPerLine * TILE_PIXEL_WIDTH,
|
|
279
|
+
tilesPerLine: this.tilesPerLine
|
|
278
280
|
};
|
|
279
281
|
case ExportFrameMode.FRAMEMODE_CROP:
|
|
280
282
|
return {
|
|
281
283
|
initialHeight: height - TILE_PIXEL_HEIGHT * FRAME_TILES,
|
|
282
|
-
initialWidth:
|
|
283
|
-
tilesPerLine:
|
|
284
|
+
initialWidth: this.tilesPerLine * TILE_PIXEL_WIDTH - TILE_PIXEL_WIDTH * FRAME_TILES,
|
|
285
|
+
tilesPerLine: this.tilesPerLine - FRAME_TILES
|
|
284
286
|
};
|
|
285
287
|
case ExportFrameMode.FRAMEMODE_SQUARE_BLACK:
|
|
286
288
|
case ExportFrameMode.FRAMEMODE_SQUARE_WHITE:
|
|
287
289
|
return {
|
|
288
290
|
initialHeight: height + 2 * TILE_PIXEL_HEIGHT,
|
|
289
|
-
initialWidth:
|
|
290
|
-
tilesPerLine:
|
|
291
|
+
initialWidth: this.tilesPerLine * TILE_PIXEL_WIDTH,
|
|
292
|
+
tilesPerLine: this.tilesPerLine
|
|
291
293
|
};
|
|
292
294
|
default:
|
|
293
295
|
throw new Error(`unknown export mode ${handleExportFrame}`);
|
|
@@ -369,13 +371,13 @@ class Decoder {
|
|
|
369
371
|
if (!this.rawImageData) {
|
|
370
372
|
return;
|
|
371
373
|
}
|
|
372
|
-
const tileXOffset = index %
|
|
373
|
-
const tileYOffset = Math.floor(index /
|
|
374
|
+
const tileXOffset = index % this.tilesPerLine;
|
|
375
|
+
const tileYOffset = Math.floor(index / this.tilesPerLine);
|
|
374
376
|
const pixelXOffset = TILE_PIXEL_WIDTH * tileXOffset;
|
|
375
377
|
const pixelYOffset = TILE_PIXEL_HEIGHT * tileYOffset;
|
|
376
378
|
for (let x = 0; x < TILE_PIXEL_WIDTH; x += 1) {
|
|
377
379
|
for (let y = 0; y < TILE_PIXEL_HEIGHT; y += 1) {
|
|
378
|
-
const rawIndex = (pixelXOffset + x + (pixelYOffset + y) *
|
|
380
|
+
const rawIndex = (pixelXOffset + x + (pixelYOffset + y) * this.tilesPerLine * TILE_PIXEL_WIDTH) * 4;
|
|
379
381
|
const color = getRGBValue({
|
|
380
382
|
pixels,
|
|
381
383
|
index: y * TILE_PIXEL_WIDTH + x,
|
|
@@ -419,7 +421,7 @@ class Decoder {
|
|
|
419
421
|
}
|
|
420
422
|
}
|
|
421
423
|
getHeight() {
|
|
422
|
-
return TILE_PIXEL_HEIGHT * Math.ceil(this.tiles.length /
|
|
424
|
+
return TILE_PIXEL_HEIGHT * Math.ceil(this.tiles.length / this.tilesPerLine);
|
|
423
425
|
}
|
|
424
426
|
}
|
|
425
427
|
|
|
@@ -437,9 +439,9 @@ var __publicField = (obj, key, value) => {
|
|
|
437
439
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
438
440
|
return value;
|
|
439
441
|
};
|
|
440
|
-
const createChannel = (key) => {
|
|
442
|
+
const createChannel = (key, tilesPerLine) => {
|
|
441
443
|
const canvas = document.createElement("canvas");
|
|
442
|
-
const decoder = new Decoder();
|
|
444
|
+
const decoder = new Decoder({ tilesPerLine });
|
|
443
445
|
decoder.update({
|
|
444
446
|
canvas,
|
|
445
447
|
tiles: [],
|
|
@@ -454,19 +456,21 @@ const createChannel = (key) => {
|
|
|
454
456
|
};
|
|
455
457
|
};
|
|
456
458
|
class RGBNDecoder {
|
|
457
|
-
constructor() {
|
|
459
|
+
constructor(options) {
|
|
458
460
|
__publicField(this, "canvas");
|
|
459
461
|
__publicField(this, "palette");
|
|
460
462
|
__publicField(this, "lockFrame");
|
|
461
463
|
__publicField(this, "channels");
|
|
464
|
+
__publicField(this, "tilesPerLine");
|
|
462
465
|
this.canvas = null;
|
|
463
466
|
this.palette = defaultPalette;
|
|
464
467
|
this.lockFrame = false;
|
|
468
|
+
this.tilesPerLine = options?.tilesPerLine || TILES_PER_LINE;
|
|
465
469
|
this.channels = {
|
|
466
|
-
r: createChannel(ChannelKey.R),
|
|
467
|
-
g: createChannel(ChannelKey.G),
|
|
468
|
-
b: createChannel(ChannelKey.B),
|
|
469
|
-
n: createChannel(ChannelKey.N)
|
|
470
|
+
r: createChannel(ChannelKey.R, this.tilesPerLine),
|
|
471
|
+
g: createChannel(ChannelKey.G, this.tilesPerLine),
|
|
472
|
+
b: createChannel(ChannelKey.B, this.tilesPerLine),
|
|
473
|
+
n: createChannel(ChannelKey.N, this.tilesPerLine)
|
|
470
474
|
};
|
|
471
475
|
}
|
|
472
476
|
update({
|
|
@@ -598,7 +602,7 @@ class RGBNDecoder {
|
|
|
598
602
|
}, 0);
|
|
599
603
|
}
|
|
600
604
|
getHeight() {
|
|
601
|
-
return TILE_PIXEL_HEIGHT * Math.ceil(this.maxTiles() /
|
|
605
|
+
return TILE_PIXEL_HEIGHT * Math.ceil(this.maxTiles() / this.tilesPerLine);
|
|
602
606
|
}
|
|
603
607
|
}
|
|
604
608
|
|