gb-image-decoder 1.3.1 → 2.0.0
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/README.md +72 -50
- package/dist/index.cjs +369 -483
- package/dist/index.d.cts +61 -84
- package/dist/index.d.mts +61 -84
- package/dist/index.d.ts +61 -84
- package/dist/index.mjs +351 -482
- package/package.json +9 -6
package/dist/index.d.cts
CHANGED
|
@@ -28,27 +28,11 @@ declare enum ExportFrameMode {
|
|
|
28
28
|
FRAMEMODE_SQUARE_BLACK = "square_black",
|
|
29
29
|
FRAMEMODE_SQUARE_WHITE = "square_white"
|
|
30
30
|
}
|
|
31
|
+
declare const channels: ChannelKey[];
|
|
31
32
|
|
|
32
|
-
interface Channel<DecoderType> {
|
|
33
|
-
key: ChannelKey;
|
|
34
|
-
tiles?: string[];
|
|
35
|
-
decoder: DecoderType;
|
|
36
|
-
canvas: HTMLCanvasElement;
|
|
37
|
-
}
|
|
38
33
|
type RGBNTiles = Partial<Record<ChannelKey, string[]>>;
|
|
39
|
-
type Channels<DecoderType> = Record<ChannelKey, Channel<DecoderType>>;
|
|
40
34
|
type SourceCanvases = Partial<Record<ChannelKey, HTMLCanvasElement>>;
|
|
41
35
|
type CanvasCreator = () => HTMLCanvasElement;
|
|
42
|
-
type ImageDataCreator = (rawImageData: Uint8ClampedArray, width: number, height: number) => ImageData;
|
|
43
|
-
interface ChangedTile {
|
|
44
|
-
index: number;
|
|
45
|
-
newTile: string;
|
|
46
|
-
}
|
|
47
|
-
interface ScaledCanvasSize {
|
|
48
|
-
initialHeight: number;
|
|
49
|
-
initialWidth: number;
|
|
50
|
-
tilesPerLine: number;
|
|
51
|
-
}
|
|
52
36
|
interface RGBValue {
|
|
53
37
|
r: number;
|
|
54
38
|
g: number;
|
|
@@ -63,94 +47,87 @@ interface RGBNPalette {
|
|
|
63
47
|
n?: number[];
|
|
64
48
|
blend?: BlendMode;
|
|
65
49
|
}
|
|
66
|
-
interface
|
|
50
|
+
interface BaseImageCreationParams<TilesType> {
|
|
51
|
+
tiles: TilesType;
|
|
52
|
+
imageStartLine?: number;
|
|
67
53
|
tilesPerLine?: number;
|
|
68
|
-
|
|
69
|
-
|
|
54
|
+
scaleFactor?: number;
|
|
55
|
+
handleExportFrame?: ExportFrameMode;
|
|
70
56
|
}
|
|
71
|
-
interface
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
palette: string[];
|
|
75
|
-
framePalette: string[];
|
|
76
|
-
imageStartLine?: number;
|
|
57
|
+
interface MonochromeImageCreationParams extends BaseImageCreationParams<string[]> {
|
|
58
|
+
imagePalette: BWPalette;
|
|
59
|
+
framePalette?: BWPalette;
|
|
77
60
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
tiles: RGBNTiles;
|
|
61
|
+
type FullMonochromeImageCreationParams = Required<MonochromeImageCreationParams>;
|
|
62
|
+
interface RGBNImageCreationParams extends BaseImageCreationParams<RGBNTiles> {
|
|
81
63
|
palette: RGBNPalette;
|
|
82
64
|
lockFrame?: boolean;
|
|
83
65
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
private colors;
|
|
89
|
-
private frameColors;
|
|
90
|
-
private rawImageData;
|
|
91
|
-
private lockFrame;
|
|
92
|
-
private colorData;
|
|
93
|
-
private frameColorData;
|
|
94
|
-
private tilesPerLine;
|
|
95
|
-
private imageStartLine;
|
|
96
|
-
private canvasCreator;
|
|
97
|
-
private imageDataCreator;
|
|
98
|
-
constructor(options?: DecoderOptions);
|
|
99
|
-
update({ canvas, tiles, palette, framePalette, imageStartLine, }: DecoderUpdateParams): void;
|
|
100
|
-
private setImageStartLine;
|
|
101
|
-
private updateCanvas;
|
|
102
|
-
getScaledCanvas(scaleFactor: number, handleExportFrame?: ExportFrameMode): HTMLCanvasElement;
|
|
103
|
-
private getScaledCanvasSize;
|
|
104
|
-
private getExportTiles;
|
|
105
|
-
private getCroppedTiles;
|
|
106
|
-
private getDefaultImageRange;
|
|
107
|
-
private setCanvas;
|
|
108
|
-
private setPalettes;
|
|
109
|
-
private setTiles;
|
|
110
|
-
private renderTile;
|
|
111
|
-
private paintTile;
|
|
112
|
-
private paintTileScaled;
|
|
113
|
-
private getHeight;
|
|
114
|
-
private getWidth;
|
|
66
|
+
type FullRGBNImageCreationParams = Required<RGBNImageCreationParams>;
|
|
67
|
+
interface PixelDimensions {
|
|
68
|
+
width: number;
|
|
69
|
+
height: number;
|
|
115
70
|
}
|
|
71
|
+
interface BaseImageContext {
|
|
72
|
+
tilesPerLine: number;
|
|
73
|
+
imageStartLine: number;
|
|
74
|
+
handleExportFrame: ExportFrameMode;
|
|
75
|
+
}
|
|
76
|
+
interface MonochromeImageContext extends BaseImageContext {
|
|
77
|
+
imagePalette: BWPalette;
|
|
78
|
+
framePalette: BWPalette;
|
|
79
|
+
}
|
|
80
|
+
interface CropResult<ContextType> {
|
|
81
|
+
tiles: string[];
|
|
82
|
+
dimensions: PixelDimensions;
|
|
83
|
+
contextUpdates: Partial<ContextType>;
|
|
84
|
+
}
|
|
85
|
+
interface RawOutput {
|
|
86
|
+
data: Uint8ClampedArray;
|
|
87
|
+
dimensions: PixelDimensions;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
declare const getDimensions: (tilesLength: number, tilesPerLine: number) => PixelDimensions;
|
|
91
|
+
declare const scaleRawImageData: (data: Uint8ClampedArray, width: number, height: number, scale: number) => RawOutput;
|
|
92
|
+
declare const getRawMonochromeImageData: (params: FullMonochromeImageCreationParams) => RawOutput;
|
|
93
|
+
declare const getMonochromeImageUrl: (params: MonochromeImageCreationParams, canvasCreator?: CanvasCreator) => Promise<string>;
|
|
94
|
+
|
|
95
|
+
declare const getRawRGBNImageData: (params: FullRGBNImageCreationParams, canvasCreator: CanvasCreator) => RawOutput;
|
|
96
|
+
declare const getRGBNImageUrl: (params: RGBNImageCreationParams, canvasCreator?: CanvasCreator) => Promise<string>;
|
|
116
97
|
|
|
117
|
-
declare class
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
private tilesPerLine;
|
|
123
|
-
private canvasCreator;
|
|
124
|
-
private imageDataCreator;
|
|
125
|
-
constructor(options?: DecoderOptions);
|
|
126
|
-
update({ canvas, tiles, palette, lockFrame, }: RGBNDecoderUpdateParams): void;
|
|
127
|
-
private setPalette;
|
|
128
|
-
private setCanvas;
|
|
129
|
-
private setLockFrame;
|
|
130
|
-
private setTiles;
|
|
131
|
-
private blendCanvases;
|
|
132
|
-
getScaledCanvas(scaleFactor: number, handleExportFrame?: ExportFrameMode): HTMLCanvasElement;
|
|
133
|
-
private getDimensions;
|
|
98
|
+
declare class UrlCache {
|
|
99
|
+
static rendered: Record<string, string>;
|
|
100
|
+
static rendering: Record<string, Promise<string>>;
|
|
101
|
+
getUrl(hash: string): Promise<string | null>;
|
|
102
|
+
setUrl(hash: string, promise: Promise<string>): Promise<void>;
|
|
134
103
|
}
|
|
135
104
|
|
|
136
105
|
declare const decodeTile: (rawBytes?: string) => IndexedTilePixels;
|
|
137
106
|
|
|
138
|
-
declare const getRGBValue: ({ pixels, index, tileIndex, imageStartLine, handleExportFrame,
|
|
107
|
+
declare const getRGBValue: ({ pixels, index, tileIndex, imageContext: { imageStartLine, handleExportFrame, imagePalette, framePalette, }, }: {
|
|
139
108
|
pixels: IndexedTilePixels;
|
|
140
109
|
index: number;
|
|
141
110
|
tileIndex: number;
|
|
142
|
-
|
|
143
|
-
handleExportFrame: ExportFrameMode;
|
|
144
|
-
colorData: BWPalette;
|
|
145
|
-
frameColorData: BWPalette;
|
|
111
|
+
imageContext: MonochromeImageContext;
|
|
146
112
|
}) => RGBValue;
|
|
147
113
|
|
|
148
|
-
declare const tileIndexIsPartOfFrame: (tileIndex: number, imageStartLine: number, handleExportFrame
|
|
114
|
+
declare const tileIndexIsPartOfFrame: (tileIndex: number, imageStartLine: number, handleExportFrame: ExportFrameMode) => boolean;
|
|
149
115
|
|
|
150
116
|
declare const maxTiles: (rgbnTiles: RGBNTiles) => number;
|
|
151
117
|
|
|
118
|
+
declare const BLACK = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF";
|
|
119
|
+
declare const WHITE = "00000000000000000000000000000000";
|
|
152
120
|
declare const SKIP_LINE = "skip";
|
|
121
|
+
declare const TILE_PIXEL_WIDTH = 8;
|
|
122
|
+
declare const TILE_PIXEL_HEIGHT = 8;
|
|
123
|
+
declare const TILES_PER_LINE = 20;
|
|
124
|
+
declare const TILES_PER_COLUMN = 18;
|
|
125
|
+
declare const FRAME_WIDTH = 2;
|
|
153
126
|
declare const BW_PALETTE: number[];
|
|
154
127
|
declare const BW_PALETTE_HEX: string[];
|
|
128
|
+
declare const BLACK_LINE: string[];
|
|
129
|
+
declare const WHITE_LINE: string[];
|
|
130
|
+
declare const RGBN_SHADES: number[];
|
|
131
|
+
declare const defaultRGBNPalette: RGBNPalette;
|
|
155
132
|
|
|
156
|
-
export { type BWPalette, BW_PALETTE, BW_PALETTE_HEX,
|
|
133
|
+
export { BLACK, BLACK_LINE, type BWPalette, BW_PALETTE, BW_PALETTE_HEX, type BaseImageContext, type BaseImageCreationParams, BlendMode, type CanvasCreator, ChannelKey, type CropResult, ExportFrameMode, FRAME_WIDTH, type FullMonochromeImageCreationParams, type FullRGBNImageCreationParams, type IndexedTilePixels, type MonochromeImageContext, type MonochromeImageCreationParams, type PixelDimensions, type RGBNImageCreationParams, type RGBNPalette, type RGBNTiles, RGBN_SHADES, type RGBValue, type RawOutput, SKIP_LINE, type SourceCanvases, TILES_PER_COLUMN, TILES_PER_LINE, TILE_PIXEL_HEIGHT, TILE_PIXEL_WIDTH, UrlCache, WHITE, WHITE_LINE, blendModeNewName, channels, decodeTile, defaultRGBNPalette, getDimensions, getMonochromeImageUrl, getRGBNImageUrl, getRGBValue, getRawMonochromeImageData, getRawRGBNImageData, maxTiles, scaleRawImageData, tileIndexIsPartOfFrame };
|
package/dist/index.d.mts
CHANGED
|
@@ -28,27 +28,11 @@ declare enum ExportFrameMode {
|
|
|
28
28
|
FRAMEMODE_SQUARE_BLACK = "square_black",
|
|
29
29
|
FRAMEMODE_SQUARE_WHITE = "square_white"
|
|
30
30
|
}
|
|
31
|
+
declare const channels: ChannelKey[];
|
|
31
32
|
|
|
32
|
-
interface Channel<DecoderType> {
|
|
33
|
-
key: ChannelKey;
|
|
34
|
-
tiles?: string[];
|
|
35
|
-
decoder: DecoderType;
|
|
36
|
-
canvas: HTMLCanvasElement;
|
|
37
|
-
}
|
|
38
33
|
type RGBNTiles = Partial<Record<ChannelKey, string[]>>;
|
|
39
|
-
type Channels<DecoderType> = Record<ChannelKey, Channel<DecoderType>>;
|
|
40
34
|
type SourceCanvases = Partial<Record<ChannelKey, HTMLCanvasElement>>;
|
|
41
35
|
type CanvasCreator = () => HTMLCanvasElement;
|
|
42
|
-
type ImageDataCreator = (rawImageData: Uint8ClampedArray, width: number, height: number) => ImageData;
|
|
43
|
-
interface ChangedTile {
|
|
44
|
-
index: number;
|
|
45
|
-
newTile: string;
|
|
46
|
-
}
|
|
47
|
-
interface ScaledCanvasSize {
|
|
48
|
-
initialHeight: number;
|
|
49
|
-
initialWidth: number;
|
|
50
|
-
tilesPerLine: number;
|
|
51
|
-
}
|
|
52
36
|
interface RGBValue {
|
|
53
37
|
r: number;
|
|
54
38
|
g: number;
|
|
@@ -63,94 +47,87 @@ interface RGBNPalette {
|
|
|
63
47
|
n?: number[];
|
|
64
48
|
blend?: BlendMode;
|
|
65
49
|
}
|
|
66
|
-
interface
|
|
50
|
+
interface BaseImageCreationParams<TilesType> {
|
|
51
|
+
tiles: TilesType;
|
|
52
|
+
imageStartLine?: number;
|
|
67
53
|
tilesPerLine?: number;
|
|
68
|
-
|
|
69
|
-
|
|
54
|
+
scaleFactor?: number;
|
|
55
|
+
handleExportFrame?: ExportFrameMode;
|
|
70
56
|
}
|
|
71
|
-
interface
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
palette: string[];
|
|
75
|
-
framePalette: string[];
|
|
76
|
-
imageStartLine?: number;
|
|
57
|
+
interface MonochromeImageCreationParams extends BaseImageCreationParams<string[]> {
|
|
58
|
+
imagePalette: BWPalette;
|
|
59
|
+
framePalette?: BWPalette;
|
|
77
60
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
tiles: RGBNTiles;
|
|
61
|
+
type FullMonochromeImageCreationParams = Required<MonochromeImageCreationParams>;
|
|
62
|
+
interface RGBNImageCreationParams extends BaseImageCreationParams<RGBNTiles> {
|
|
81
63
|
palette: RGBNPalette;
|
|
82
64
|
lockFrame?: boolean;
|
|
83
65
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
private colors;
|
|
89
|
-
private frameColors;
|
|
90
|
-
private rawImageData;
|
|
91
|
-
private lockFrame;
|
|
92
|
-
private colorData;
|
|
93
|
-
private frameColorData;
|
|
94
|
-
private tilesPerLine;
|
|
95
|
-
private imageStartLine;
|
|
96
|
-
private canvasCreator;
|
|
97
|
-
private imageDataCreator;
|
|
98
|
-
constructor(options?: DecoderOptions);
|
|
99
|
-
update({ canvas, tiles, palette, framePalette, imageStartLine, }: DecoderUpdateParams): void;
|
|
100
|
-
private setImageStartLine;
|
|
101
|
-
private updateCanvas;
|
|
102
|
-
getScaledCanvas(scaleFactor: number, handleExportFrame?: ExportFrameMode): HTMLCanvasElement;
|
|
103
|
-
private getScaledCanvasSize;
|
|
104
|
-
private getExportTiles;
|
|
105
|
-
private getCroppedTiles;
|
|
106
|
-
private getDefaultImageRange;
|
|
107
|
-
private setCanvas;
|
|
108
|
-
private setPalettes;
|
|
109
|
-
private setTiles;
|
|
110
|
-
private renderTile;
|
|
111
|
-
private paintTile;
|
|
112
|
-
private paintTileScaled;
|
|
113
|
-
private getHeight;
|
|
114
|
-
private getWidth;
|
|
66
|
+
type FullRGBNImageCreationParams = Required<RGBNImageCreationParams>;
|
|
67
|
+
interface PixelDimensions {
|
|
68
|
+
width: number;
|
|
69
|
+
height: number;
|
|
115
70
|
}
|
|
71
|
+
interface BaseImageContext {
|
|
72
|
+
tilesPerLine: number;
|
|
73
|
+
imageStartLine: number;
|
|
74
|
+
handleExportFrame: ExportFrameMode;
|
|
75
|
+
}
|
|
76
|
+
interface MonochromeImageContext extends BaseImageContext {
|
|
77
|
+
imagePalette: BWPalette;
|
|
78
|
+
framePalette: BWPalette;
|
|
79
|
+
}
|
|
80
|
+
interface CropResult<ContextType> {
|
|
81
|
+
tiles: string[];
|
|
82
|
+
dimensions: PixelDimensions;
|
|
83
|
+
contextUpdates: Partial<ContextType>;
|
|
84
|
+
}
|
|
85
|
+
interface RawOutput {
|
|
86
|
+
data: Uint8ClampedArray;
|
|
87
|
+
dimensions: PixelDimensions;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
declare const getDimensions: (tilesLength: number, tilesPerLine: number) => PixelDimensions;
|
|
91
|
+
declare const scaleRawImageData: (data: Uint8ClampedArray, width: number, height: number, scale: number) => RawOutput;
|
|
92
|
+
declare const getRawMonochromeImageData: (params: FullMonochromeImageCreationParams) => RawOutput;
|
|
93
|
+
declare const getMonochromeImageUrl: (params: MonochromeImageCreationParams, canvasCreator?: CanvasCreator) => Promise<string>;
|
|
94
|
+
|
|
95
|
+
declare const getRawRGBNImageData: (params: FullRGBNImageCreationParams, canvasCreator: CanvasCreator) => RawOutput;
|
|
96
|
+
declare const getRGBNImageUrl: (params: RGBNImageCreationParams, canvasCreator?: CanvasCreator) => Promise<string>;
|
|
116
97
|
|
|
117
|
-
declare class
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
private tilesPerLine;
|
|
123
|
-
private canvasCreator;
|
|
124
|
-
private imageDataCreator;
|
|
125
|
-
constructor(options?: DecoderOptions);
|
|
126
|
-
update({ canvas, tiles, palette, lockFrame, }: RGBNDecoderUpdateParams): void;
|
|
127
|
-
private setPalette;
|
|
128
|
-
private setCanvas;
|
|
129
|
-
private setLockFrame;
|
|
130
|
-
private setTiles;
|
|
131
|
-
private blendCanvases;
|
|
132
|
-
getScaledCanvas(scaleFactor: number, handleExportFrame?: ExportFrameMode): HTMLCanvasElement;
|
|
133
|
-
private getDimensions;
|
|
98
|
+
declare class UrlCache {
|
|
99
|
+
static rendered: Record<string, string>;
|
|
100
|
+
static rendering: Record<string, Promise<string>>;
|
|
101
|
+
getUrl(hash: string): Promise<string | null>;
|
|
102
|
+
setUrl(hash: string, promise: Promise<string>): Promise<void>;
|
|
134
103
|
}
|
|
135
104
|
|
|
136
105
|
declare const decodeTile: (rawBytes?: string) => IndexedTilePixels;
|
|
137
106
|
|
|
138
|
-
declare const getRGBValue: ({ pixels, index, tileIndex, imageStartLine, handleExportFrame,
|
|
107
|
+
declare const getRGBValue: ({ pixels, index, tileIndex, imageContext: { imageStartLine, handleExportFrame, imagePalette, framePalette, }, }: {
|
|
139
108
|
pixels: IndexedTilePixels;
|
|
140
109
|
index: number;
|
|
141
110
|
tileIndex: number;
|
|
142
|
-
|
|
143
|
-
handleExportFrame: ExportFrameMode;
|
|
144
|
-
colorData: BWPalette;
|
|
145
|
-
frameColorData: BWPalette;
|
|
111
|
+
imageContext: MonochromeImageContext;
|
|
146
112
|
}) => RGBValue;
|
|
147
113
|
|
|
148
|
-
declare const tileIndexIsPartOfFrame: (tileIndex: number, imageStartLine: number, handleExportFrame
|
|
114
|
+
declare const tileIndexIsPartOfFrame: (tileIndex: number, imageStartLine: number, handleExportFrame: ExportFrameMode) => boolean;
|
|
149
115
|
|
|
150
116
|
declare const maxTiles: (rgbnTiles: RGBNTiles) => number;
|
|
151
117
|
|
|
118
|
+
declare const BLACK = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF";
|
|
119
|
+
declare const WHITE = "00000000000000000000000000000000";
|
|
152
120
|
declare const SKIP_LINE = "skip";
|
|
121
|
+
declare const TILE_PIXEL_WIDTH = 8;
|
|
122
|
+
declare const TILE_PIXEL_HEIGHT = 8;
|
|
123
|
+
declare const TILES_PER_LINE = 20;
|
|
124
|
+
declare const TILES_PER_COLUMN = 18;
|
|
125
|
+
declare const FRAME_WIDTH = 2;
|
|
153
126
|
declare const BW_PALETTE: number[];
|
|
154
127
|
declare const BW_PALETTE_HEX: string[];
|
|
128
|
+
declare const BLACK_LINE: string[];
|
|
129
|
+
declare const WHITE_LINE: string[];
|
|
130
|
+
declare const RGBN_SHADES: number[];
|
|
131
|
+
declare const defaultRGBNPalette: RGBNPalette;
|
|
155
132
|
|
|
156
|
-
export { type BWPalette, BW_PALETTE, BW_PALETTE_HEX,
|
|
133
|
+
export { BLACK, BLACK_LINE, type BWPalette, BW_PALETTE, BW_PALETTE_HEX, type BaseImageContext, type BaseImageCreationParams, BlendMode, type CanvasCreator, ChannelKey, type CropResult, ExportFrameMode, FRAME_WIDTH, type FullMonochromeImageCreationParams, type FullRGBNImageCreationParams, type IndexedTilePixels, type MonochromeImageContext, type MonochromeImageCreationParams, type PixelDimensions, type RGBNImageCreationParams, type RGBNPalette, type RGBNTiles, RGBN_SHADES, type RGBValue, type RawOutput, SKIP_LINE, type SourceCanvases, TILES_PER_COLUMN, TILES_PER_LINE, TILE_PIXEL_HEIGHT, TILE_PIXEL_WIDTH, UrlCache, WHITE, WHITE_LINE, blendModeNewName, channels, decodeTile, defaultRGBNPalette, getDimensions, getMonochromeImageUrl, getRGBNImageUrl, getRGBValue, getRawMonochromeImageData, getRawRGBNImageData, maxTiles, scaleRawImageData, tileIndexIsPartOfFrame };
|
package/dist/index.d.ts
CHANGED
|
@@ -28,27 +28,11 @@ declare enum ExportFrameMode {
|
|
|
28
28
|
FRAMEMODE_SQUARE_BLACK = "square_black",
|
|
29
29
|
FRAMEMODE_SQUARE_WHITE = "square_white"
|
|
30
30
|
}
|
|
31
|
+
declare const channels: ChannelKey[];
|
|
31
32
|
|
|
32
|
-
interface Channel<DecoderType> {
|
|
33
|
-
key: ChannelKey;
|
|
34
|
-
tiles?: string[];
|
|
35
|
-
decoder: DecoderType;
|
|
36
|
-
canvas: HTMLCanvasElement;
|
|
37
|
-
}
|
|
38
33
|
type RGBNTiles = Partial<Record<ChannelKey, string[]>>;
|
|
39
|
-
type Channels<DecoderType> = Record<ChannelKey, Channel<DecoderType>>;
|
|
40
34
|
type SourceCanvases = Partial<Record<ChannelKey, HTMLCanvasElement>>;
|
|
41
35
|
type CanvasCreator = () => HTMLCanvasElement;
|
|
42
|
-
type ImageDataCreator = (rawImageData: Uint8ClampedArray, width: number, height: number) => ImageData;
|
|
43
|
-
interface ChangedTile {
|
|
44
|
-
index: number;
|
|
45
|
-
newTile: string;
|
|
46
|
-
}
|
|
47
|
-
interface ScaledCanvasSize {
|
|
48
|
-
initialHeight: number;
|
|
49
|
-
initialWidth: number;
|
|
50
|
-
tilesPerLine: number;
|
|
51
|
-
}
|
|
52
36
|
interface RGBValue {
|
|
53
37
|
r: number;
|
|
54
38
|
g: number;
|
|
@@ -63,94 +47,87 @@ interface RGBNPalette {
|
|
|
63
47
|
n?: number[];
|
|
64
48
|
blend?: BlendMode;
|
|
65
49
|
}
|
|
66
|
-
interface
|
|
50
|
+
interface BaseImageCreationParams<TilesType> {
|
|
51
|
+
tiles: TilesType;
|
|
52
|
+
imageStartLine?: number;
|
|
67
53
|
tilesPerLine?: number;
|
|
68
|
-
|
|
69
|
-
|
|
54
|
+
scaleFactor?: number;
|
|
55
|
+
handleExportFrame?: ExportFrameMode;
|
|
70
56
|
}
|
|
71
|
-
interface
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
palette: string[];
|
|
75
|
-
framePalette: string[];
|
|
76
|
-
imageStartLine?: number;
|
|
57
|
+
interface MonochromeImageCreationParams extends BaseImageCreationParams<string[]> {
|
|
58
|
+
imagePalette: BWPalette;
|
|
59
|
+
framePalette?: BWPalette;
|
|
77
60
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
tiles: RGBNTiles;
|
|
61
|
+
type FullMonochromeImageCreationParams = Required<MonochromeImageCreationParams>;
|
|
62
|
+
interface RGBNImageCreationParams extends BaseImageCreationParams<RGBNTiles> {
|
|
81
63
|
palette: RGBNPalette;
|
|
82
64
|
lockFrame?: boolean;
|
|
83
65
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
private colors;
|
|
89
|
-
private frameColors;
|
|
90
|
-
private rawImageData;
|
|
91
|
-
private lockFrame;
|
|
92
|
-
private colorData;
|
|
93
|
-
private frameColorData;
|
|
94
|
-
private tilesPerLine;
|
|
95
|
-
private imageStartLine;
|
|
96
|
-
private canvasCreator;
|
|
97
|
-
private imageDataCreator;
|
|
98
|
-
constructor(options?: DecoderOptions);
|
|
99
|
-
update({ canvas, tiles, palette, framePalette, imageStartLine, }: DecoderUpdateParams): void;
|
|
100
|
-
private setImageStartLine;
|
|
101
|
-
private updateCanvas;
|
|
102
|
-
getScaledCanvas(scaleFactor: number, handleExportFrame?: ExportFrameMode): HTMLCanvasElement;
|
|
103
|
-
private getScaledCanvasSize;
|
|
104
|
-
private getExportTiles;
|
|
105
|
-
private getCroppedTiles;
|
|
106
|
-
private getDefaultImageRange;
|
|
107
|
-
private setCanvas;
|
|
108
|
-
private setPalettes;
|
|
109
|
-
private setTiles;
|
|
110
|
-
private renderTile;
|
|
111
|
-
private paintTile;
|
|
112
|
-
private paintTileScaled;
|
|
113
|
-
private getHeight;
|
|
114
|
-
private getWidth;
|
|
66
|
+
type FullRGBNImageCreationParams = Required<RGBNImageCreationParams>;
|
|
67
|
+
interface PixelDimensions {
|
|
68
|
+
width: number;
|
|
69
|
+
height: number;
|
|
115
70
|
}
|
|
71
|
+
interface BaseImageContext {
|
|
72
|
+
tilesPerLine: number;
|
|
73
|
+
imageStartLine: number;
|
|
74
|
+
handleExportFrame: ExportFrameMode;
|
|
75
|
+
}
|
|
76
|
+
interface MonochromeImageContext extends BaseImageContext {
|
|
77
|
+
imagePalette: BWPalette;
|
|
78
|
+
framePalette: BWPalette;
|
|
79
|
+
}
|
|
80
|
+
interface CropResult<ContextType> {
|
|
81
|
+
tiles: string[];
|
|
82
|
+
dimensions: PixelDimensions;
|
|
83
|
+
contextUpdates: Partial<ContextType>;
|
|
84
|
+
}
|
|
85
|
+
interface RawOutput {
|
|
86
|
+
data: Uint8ClampedArray;
|
|
87
|
+
dimensions: PixelDimensions;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
declare const getDimensions: (tilesLength: number, tilesPerLine: number) => PixelDimensions;
|
|
91
|
+
declare const scaleRawImageData: (data: Uint8ClampedArray, width: number, height: number, scale: number) => RawOutput;
|
|
92
|
+
declare const getRawMonochromeImageData: (params: FullMonochromeImageCreationParams) => RawOutput;
|
|
93
|
+
declare const getMonochromeImageUrl: (params: MonochromeImageCreationParams, canvasCreator?: CanvasCreator) => Promise<string>;
|
|
94
|
+
|
|
95
|
+
declare const getRawRGBNImageData: (params: FullRGBNImageCreationParams, canvasCreator: CanvasCreator) => RawOutput;
|
|
96
|
+
declare const getRGBNImageUrl: (params: RGBNImageCreationParams, canvasCreator?: CanvasCreator) => Promise<string>;
|
|
116
97
|
|
|
117
|
-
declare class
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
private tilesPerLine;
|
|
123
|
-
private canvasCreator;
|
|
124
|
-
private imageDataCreator;
|
|
125
|
-
constructor(options?: DecoderOptions);
|
|
126
|
-
update({ canvas, tiles, palette, lockFrame, }: RGBNDecoderUpdateParams): void;
|
|
127
|
-
private setPalette;
|
|
128
|
-
private setCanvas;
|
|
129
|
-
private setLockFrame;
|
|
130
|
-
private setTiles;
|
|
131
|
-
private blendCanvases;
|
|
132
|
-
getScaledCanvas(scaleFactor: number, handleExportFrame?: ExportFrameMode): HTMLCanvasElement;
|
|
133
|
-
private getDimensions;
|
|
98
|
+
declare class UrlCache {
|
|
99
|
+
static rendered: Record<string, string>;
|
|
100
|
+
static rendering: Record<string, Promise<string>>;
|
|
101
|
+
getUrl(hash: string): Promise<string | null>;
|
|
102
|
+
setUrl(hash: string, promise: Promise<string>): Promise<void>;
|
|
134
103
|
}
|
|
135
104
|
|
|
136
105
|
declare const decodeTile: (rawBytes?: string) => IndexedTilePixels;
|
|
137
106
|
|
|
138
|
-
declare const getRGBValue: ({ pixels, index, tileIndex, imageStartLine, handleExportFrame,
|
|
107
|
+
declare const getRGBValue: ({ pixels, index, tileIndex, imageContext: { imageStartLine, handleExportFrame, imagePalette, framePalette, }, }: {
|
|
139
108
|
pixels: IndexedTilePixels;
|
|
140
109
|
index: number;
|
|
141
110
|
tileIndex: number;
|
|
142
|
-
|
|
143
|
-
handleExportFrame: ExportFrameMode;
|
|
144
|
-
colorData: BWPalette;
|
|
145
|
-
frameColorData: BWPalette;
|
|
111
|
+
imageContext: MonochromeImageContext;
|
|
146
112
|
}) => RGBValue;
|
|
147
113
|
|
|
148
|
-
declare const tileIndexIsPartOfFrame: (tileIndex: number, imageStartLine: number, handleExportFrame
|
|
114
|
+
declare const tileIndexIsPartOfFrame: (tileIndex: number, imageStartLine: number, handleExportFrame: ExportFrameMode) => boolean;
|
|
149
115
|
|
|
150
116
|
declare const maxTiles: (rgbnTiles: RGBNTiles) => number;
|
|
151
117
|
|
|
118
|
+
declare const BLACK = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF";
|
|
119
|
+
declare const WHITE = "00000000000000000000000000000000";
|
|
152
120
|
declare const SKIP_LINE = "skip";
|
|
121
|
+
declare const TILE_PIXEL_WIDTH = 8;
|
|
122
|
+
declare const TILE_PIXEL_HEIGHT = 8;
|
|
123
|
+
declare const TILES_PER_LINE = 20;
|
|
124
|
+
declare const TILES_PER_COLUMN = 18;
|
|
125
|
+
declare const FRAME_WIDTH = 2;
|
|
153
126
|
declare const BW_PALETTE: number[];
|
|
154
127
|
declare const BW_PALETTE_HEX: string[];
|
|
128
|
+
declare const BLACK_LINE: string[];
|
|
129
|
+
declare const WHITE_LINE: string[];
|
|
130
|
+
declare const RGBN_SHADES: number[];
|
|
131
|
+
declare const defaultRGBNPalette: RGBNPalette;
|
|
155
132
|
|
|
156
|
-
export { type BWPalette, BW_PALETTE, BW_PALETTE_HEX,
|
|
133
|
+
export { BLACK, BLACK_LINE, type BWPalette, BW_PALETTE, BW_PALETTE_HEX, type BaseImageContext, type BaseImageCreationParams, BlendMode, type CanvasCreator, ChannelKey, type CropResult, ExportFrameMode, FRAME_WIDTH, type FullMonochromeImageCreationParams, type FullRGBNImageCreationParams, type IndexedTilePixels, type MonochromeImageContext, type MonochromeImageCreationParams, type PixelDimensions, type RGBNImageCreationParams, type RGBNPalette, type RGBNTiles, RGBN_SHADES, type RGBValue, type RawOutput, SKIP_LINE, type SourceCanvases, TILES_PER_COLUMN, TILES_PER_LINE, TILE_PIXEL_HEIGHT, TILE_PIXEL_WIDTH, UrlCache, WHITE, WHITE_LINE, blendModeNewName, channels, decodeTile, defaultRGBNPalette, getDimensions, getMonochromeImageUrl, getRGBNImageUrl, getRGBValue, getRawMonochromeImageData, getRawRGBNImageData, maxTiles, scaleRawImageData, tileIndexIsPartOfFrame };
|