gb-image-decoder 0.0.1

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.
@@ -0,0 +1,131 @@
1
+ declare enum BlendMode {
2
+ NORMAL = "normal",// skip N-Layer
3
+ NORMAL_S = "normal_s",// This is the default setting and draws new shapes on top of the existing canvas content.
4
+ LIGHTEN = "lighten",// Retains the lightest pixels of both layers.
5
+ SCREEN = "screen",// The pixels are inverted, multiplied, and inverted again. A lighter picture is the result (opposite of multiply)
6
+ DODGE = "dodge",// Divides the bottom layer by the inverted top layer.
7
+ ADDITION = "addition",// Where both shapes overlap, the color is determined by adding color values.
8
+ DARKEN = "darken",// Retains the darkest pixels of both layers.
9
+ MULTIPLY = "multiply",// The pixels of the top layer are multiplied with the corresponding pixels of the bottom layer. A darker picture is the result.
10
+ BURN = "burn",// Divides the inverted bottom layer by the top layer, and then inverts the result.
11
+ OVERLAY = "overlay",// A combination of multiply and screen. Dark parts on the base layer become darker, and light parts become lighter.
12
+ SOFTLIGHT = "softlight",// A softer version of hard-light. Pure black or white does not result in pure black or white.
13
+ HARDLIGHT = "hardlight",// Like overlay, a combination of multiply and screen — but instead with the top layer and bottom layer swapped.
14
+ DIFFERENCE = "difference",// Subtracts the bottom layer from the top layer — or the other way round — to always get a positive value.
15
+ EXCLUSION = "exclusion"
16
+ }
17
+ declare const blendModeNewName: (oldName?: BlendMode) => GlobalCompositeOperation;
18
+
19
+ declare enum ChannelKey {
20
+ R = "r",
21
+ G = "g",
22
+ B = "b",
23
+ N = "n"
24
+ }
25
+ declare enum ExportFrameMode {
26
+ FRAMEMODE_KEEP = "keep",
27
+ FRAMEMODE_CROP = "crop",
28
+ FRAMEMODE_SQUARE_BLACK = "square_black",
29
+ FRAMEMODE_SQUARE_WHITE = "square_white"
30
+ }
31
+
32
+ interface Channel<DecoderType> {
33
+ key: ChannelKey;
34
+ tiles?: string[];
35
+ decoder: DecoderType;
36
+ canvas: HTMLCanvasElement;
37
+ }
38
+ type RGBNTiles = Partial<Record<ChannelKey, string[]>>;
39
+ type Channels<DecoderType> = Record<ChannelKey, Channel<DecoderType>>;
40
+ type SourceCanvases = Partial<Record<ChannelKey, HTMLCanvasElement>>;
41
+ interface ChangedTile {
42
+ index: number;
43
+ newTile: string;
44
+ }
45
+ interface ScaledCanvasSize {
46
+ initialHeight: number;
47
+ initialWidth: number;
48
+ tilesPerLine: number;
49
+ }
50
+ interface RGBValue {
51
+ r: number;
52
+ g: number;
53
+ b: number;
54
+ }
55
+ type BWPalette = number[];
56
+ type IndexedTilePixels = number[];
57
+ interface RGBNPalette {
58
+ r?: number[];
59
+ g?: number[];
60
+ b?: number[];
61
+ n?: number[];
62
+ blend?: BlendMode;
63
+ }
64
+
65
+ declare class Decoder {
66
+ private canvas;
67
+ private tiles;
68
+ private colors;
69
+ private rawImageData;
70
+ private lockFrame;
71
+ private invertPalette;
72
+ private colorData;
73
+ constructor();
74
+ update({ canvas, tiles, palette, lockFrame, invertPalette, }: {
75
+ canvas: HTMLCanvasElement | null;
76
+ tiles: string[];
77
+ palette: string[];
78
+ lockFrame: boolean;
79
+ invertPalette: boolean;
80
+ }): void;
81
+ private updateCanvas;
82
+ getScaledCanvas(scaleFactor: number, handleExportFrame?: ExportFrameMode): HTMLCanvasElement;
83
+ static getScaledCanvasSize(handleExportFrame: ExportFrameMode, height: number): ScaledCanvasSize;
84
+ private getExportTiles;
85
+ private setCanvas;
86
+ private setPalette;
87
+ private setLockFrame;
88
+ private setTiles;
89
+ private renderTile;
90
+ private paintTile;
91
+ private paintTileScaled;
92
+ private getHeight;
93
+ }
94
+
95
+ declare class RGBNDecoder {
96
+ private canvas;
97
+ private palette;
98
+ private lockFrame;
99
+ private channels;
100
+ constructor();
101
+ update({ canvas, tiles, palette, lockFrame, }: {
102
+ canvas: HTMLCanvasElement | null;
103
+ tiles: RGBNTiles;
104
+ palette: RGBNPalette;
105
+ lockFrame: boolean;
106
+ }): void;
107
+ private setPalette;
108
+ private setCanvas;
109
+ private setLockFrame;
110
+ private setTiles;
111
+ private blendCanvases;
112
+ getScaledCanvas(scaleFactor: number, handleExportFrame?: ExportFrameMode): HTMLCanvasElement;
113
+ private maxTiles;
114
+ private getHeight;
115
+ }
116
+
117
+ declare const decodeTile: (rawBytes?: string) => IndexedTilePixels;
118
+
119
+ declare const getRGBValue: ({ pixels, index, tileIndex, handleExportFrame, lockFrame, invertPalette, colorData, }: {
120
+ pixels: IndexedTilePixels;
121
+ index: number;
122
+ tileIndex: number;
123
+ handleExportFrame: ExportFrameMode;
124
+ lockFrame: boolean;
125
+ invertPalette: boolean;
126
+ colorData: BWPalette;
127
+ }) => RGBValue;
128
+
129
+ declare const tileIndexIsPartOfFrame: (tileIndex: number, handleExportFrame?: ExportFrameMode) => boolean;
130
+
131
+ export { type BWPalette, BlendMode, type ChangedTile, type Channel, type Channels, Decoder, ExportFrameMode, type IndexedTilePixels, RGBNDecoder, type RGBNPalette, type RGBNTiles, type RGBValue, type ScaledCanvasSize, type SourceCanvases, blendModeNewName, decodeTile, getRGBValue, tileIndexIsPartOfFrame };
@@ -0,0 +1,131 @@
1
+ declare enum BlendMode {
2
+ NORMAL = "normal",// skip N-Layer
3
+ NORMAL_S = "normal_s",// This is the default setting and draws new shapes on top of the existing canvas content.
4
+ LIGHTEN = "lighten",// Retains the lightest pixels of both layers.
5
+ SCREEN = "screen",// The pixels are inverted, multiplied, and inverted again. A lighter picture is the result (opposite of multiply)
6
+ DODGE = "dodge",// Divides the bottom layer by the inverted top layer.
7
+ ADDITION = "addition",// Where both shapes overlap, the color is determined by adding color values.
8
+ DARKEN = "darken",// Retains the darkest pixels of both layers.
9
+ MULTIPLY = "multiply",// The pixels of the top layer are multiplied with the corresponding pixels of the bottom layer. A darker picture is the result.
10
+ BURN = "burn",// Divides the inverted bottom layer by the top layer, and then inverts the result.
11
+ OVERLAY = "overlay",// A combination of multiply and screen. Dark parts on the base layer become darker, and light parts become lighter.
12
+ SOFTLIGHT = "softlight",// A softer version of hard-light. Pure black or white does not result in pure black or white.
13
+ HARDLIGHT = "hardlight",// Like overlay, a combination of multiply and screen — but instead with the top layer and bottom layer swapped.
14
+ DIFFERENCE = "difference",// Subtracts the bottom layer from the top layer — or the other way round — to always get a positive value.
15
+ EXCLUSION = "exclusion"
16
+ }
17
+ declare const blendModeNewName: (oldName?: BlendMode) => GlobalCompositeOperation;
18
+
19
+ declare enum ChannelKey {
20
+ R = "r",
21
+ G = "g",
22
+ B = "b",
23
+ N = "n"
24
+ }
25
+ declare enum ExportFrameMode {
26
+ FRAMEMODE_KEEP = "keep",
27
+ FRAMEMODE_CROP = "crop",
28
+ FRAMEMODE_SQUARE_BLACK = "square_black",
29
+ FRAMEMODE_SQUARE_WHITE = "square_white"
30
+ }
31
+
32
+ interface Channel<DecoderType> {
33
+ key: ChannelKey;
34
+ tiles?: string[];
35
+ decoder: DecoderType;
36
+ canvas: HTMLCanvasElement;
37
+ }
38
+ type RGBNTiles = Partial<Record<ChannelKey, string[]>>;
39
+ type Channels<DecoderType> = Record<ChannelKey, Channel<DecoderType>>;
40
+ type SourceCanvases = Partial<Record<ChannelKey, HTMLCanvasElement>>;
41
+ interface ChangedTile {
42
+ index: number;
43
+ newTile: string;
44
+ }
45
+ interface ScaledCanvasSize {
46
+ initialHeight: number;
47
+ initialWidth: number;
48
+ tilesPerLine: number;
49
+ }
50
+ interface RGBValue {
51
+ r: number;
52
+ g: number;
53
+ b: number;
54
+ }
55
+ type BWPalette = number[];
56
+ type IndexedTilePixels = number[];
57
+ interface RGBNPalette {
58
+ r?: number[];
59
+ g?: number[];
60
+ b?: number[];
61
+ n?: number[];
62
+ blend?: BlendMode;
63
+ }
64
+
65
+ declare class Decoder {
66
+ private canvas;
67
+ private tiles;
68
+ private colors;
69
+ private rawImageData;
70
+ private lockFrame;
71
+ private invertPalette;
72
+ private colorData;
73
+ constructor();
74
+ update({ canvas, tiles, palette, lockFrame, invertPalette, }: {
75
+ canvas: HTMLCanvasElement | null;
76
+ tiles: string[];
77
+ palette: string[];
78
+ lockFrame: boolean;
79
+ invertPalette: boolean;
80
+ }): void;
81
+ private updateCanvas;
82
+ getScaledCanvas(scaleFactor: number, handleExportFrame?: ExportFrameMode): HTMLCanvasElement;
83
+ static getScaledCanvasSize(handleExportFrame: ExportFrameMode, height: number): ScaledCanvasSize;
84
+ private getExportTiles;
85
+ private setCanvas;
86
+ private setPalette;
87
+ private setLockFrame;
88
+ private setTiles;
89
+ private renderTile;
90
+ private paintTile;
91
+ private paintTileScaled;
92
+ private getHeight;
93
+ }
94
+
95
+ declare class RGBNDecoder {
96
+ private canvas;
97
+ private palette;
98
+ private lockFrame;
99
+ private channels;
100
+ constructor();
101
+ update({ canvas, tiles, palette, lockFrame, }: {
102
+ canvas: HTMLCanvasElement | null;
103
+ tiles: RGBNTiles;
104
+ palette: RGBNPalette;
105
+ lockFrame: boolean;
106
+ }): void;
107
+ private setPalette;
108
+ private setCanvas;
109
+ private setLockFrame;
110
+ private setTiles;
111
+ private blendCanvases;
112
+ getScaledCanvas(scaleFactor: number, handleExportFrame?: ExportFrameMode): HTMLCanvasElement;
113
+ private maxTiles;
114
+ private getHeight;
115
+ }
116
+
117
+ declare const decodeTile: (rawBytes?: string) => IndexedTilePixels;
118
+
119
+ declare const getRGBValue: ({ pixels, index, tileIndex, handleExportFrame, lockFrame, invertPalette, colorData, }: {
120
+ pixels: IndexedTilePixels;
121
+ index: number;
122
+ tileIndex: number;
123
+ handleExportFrame: ExportFrameMode;
124
+ lockFrame: boolean;
125
+ invertPalette: boolean;
126
+ colorData: BWPalette;
127
+ }) => RGBValue;
128
+
129
+ declare const tileIndexIsPartOfFrame: (tileIndex: number, handleExportFrame?: ExportFrameMode) => boolean;
130
+
131
+ export { type BWPalette, BlendMode, type ChangedTile, type Channel, type Channels, Decoder, ExportFrameMode, type IndexedTilePixels, RGBNDecoder, type RGBNPalette, type RGBNTiles, type RGBValue, type ScaledCanvasSize, type SourceCanvases, blendModeNewName, decodeTile, getRGBValue, tileIndexIsPartOfFrame };
@@ -0,0 +1,131 @@
1
+ declare enum BlendMode {
2
+ NORMAL = "normal",// skip N-Layer
3
+ NORMAL_S = "normal_s",// This is the default setting and draws new shapes on top of the existing canvas content.
4
+ LIGHTEN = "lighten",// Retains the lightest pixels of both layers.
5
+ SCREEN = "screen",// The pixels are inverted, multiplied, and inverted again. A lighter picture is the result (opposite of multiply)
6
+ DODGE = "dodge",// Divides the bottom layer by the inverted top layer.
7
+ ADDITION = "addition",// Where both shapes overlap, the color is determined by adding color values.
8
+ DARKEN = "darken",// Retains the darkest pixels of both layers.
9
+ MULTIPLY = "multiply",// The pixels of the top layer are multiplied with the corresponding pixels of the bottom layer. A darker picture is the result.
10
+ BURN = "burn",// Divides the inverted bottom layer by the top layer, and then inverts the result.
11
+ OVERLAY = "overlay",// A combination of multiply and screen. Dark parts on the base layer become darker, and light parts become lighter.
12
+ SOFTLIGHT = "softlight",// A softer version of hard-light. Pure black or white does not result in pure black or white.
13
+ HARDLIGHT = "hardlight",// Like overlay, a combination of multiply and screen — but instead with the top layer and bottom layer swapped.
14
+ DIFFERENCE = "difference",// Subtracts the bottom layer from the top layer — or the other way round — to always get a positive value.
15
+ EXCLUSION = "exclusion"
16
+ }
17
+ declare const blendModeNewName: (oldName?: BlendMode) => GlobalCompositeOperation;
18
+
19
+ declare enum ChannelKey {
20
+ R = "r",
21
+ G = "g",
22
+ B = "b",
23
+ N = "n"
24
+ }
25
+ declare enum ExportFrameMode {
26
+ FRAMEMODE_KEEP = "keep",
27
+ FRAMEMODE_CROP = "crop",
28
+ FRAMEMODE_SQUARE_BLACK = "square_black",
29
+ FRAMEMODE_SQUARE_WHITE = "square_white"
30
+ }
31
+
32
+ interface Channel<DecoderType> {
33
+ key: ChannelKey;
34
+ tiles?: string[];
35
+ decoder: DecoderType;
36
+ canvas: HTMLCanvasElement;
37
+ }
38
+ type RGBNTiles = Partial<Record<ChannelKey, string[]>>;
39
+ type Channels<DecoderType> = Record<ChannelKey, Channel<DecoderType>>;
40
+ type SourceCanvases = Partial<Record<ChannelKey, HTMLCanvasElement>>;
41
+ interface ChangedTile {
42
+ index: number;
43
+ newTile: string;
44
+ }
45
+ interface ScaledCanvasSize {
46
+ initialHeight: number;
47
+ initialWidth: number;
48
+ tilesPerLine: number;
49
+ }
50
+ interface RGBValue {
51
+ r: number;
52
+ g: number;
53
+ b: number;
54
+ }
55
+ type BWPalette = number[];
56
+ type IndexedTilePixels = number[];
57
+ interface RGBNPalette {
58
+ r?: number[];
59
+ g?: number[];
60
+ b?: number[];
61
+ n?: number[];
62
+ blend?: BlendMode;
63
+ }
64
+
65
+ declare class Decoder {
66
+ private canvas;
67
+ private tiles;
68
+ private colors;
69
+ private rawImageData;
70
+ private lockFrame;
71
+ private invertPalette;
72
+ private colorData;
73
+ constructor();
74
+ update({ canvas, tiles, palette, lockFrame, invertPalette, }: {
75
+ canvas: HTMLCanvasElement | null;
76
+ tiles: string[];
77
+ palette: string[];
78
+ lockFrame: boolean;
79
+ invertPalette: boolean;
80
+ }): void;
81
+ private updateCanvas;
82
+ getScaledCanvas(scaleFactor: number, handleExportFrame?: ExportFrameMode): HTMLCanvasElement;
83
+ static getScaledCanvasSize(handleExportFrame: ExportFrameMode, height: number): ScaledCanvasSize;
84
+ private getExportTiles;
85
+ private setCanvas;
86
+ private setPalette;
87
+ private setLockFrame;
88
+ private setTiles;
89
+ private renderTile;
90
+ private paintTile;
91
+ private paintTileScaled;
92
+ private getHeight;
93
+ }
94
+
95
+ declare class RGBNDecoder {
96
+ private canvas;
97
+ private palette;
98
+ private lockFrame;
99
+ private channels;
100
+ constructor();
101
+ update({ canvas, tiles, palette, lockFrame, }: {
102
+ canvas: HTMLCanvasElement | null;
103
+ tiles: RGBNTiles;
104
+ palette: RGBNPalette;
105
+ lockFrame: boolean;
106
+ }): void;
107
+ private setPalette;
108
+ private setCanvas;
109
+ private setLockFrame;
110
+ private setTiles;
111
+ private blendCanvases;
112
+ getScaledCanvas(scaleFactor: number, handleExportFrame?: ExportFrameMode): HTMLCanvasElement;
113
+ private maxTiles;
114
+ private getHeight;
115
+ }
116
+
117
+ declare const decodeTile: (rawBytes?: string) => IndexedTilePixels;
118
+
119
+ declare const getRGBValue: ({ pixels, index, tileIndex, handleExportFrame, lockFrame, invertPalette, colorData, }: {
120
+ pixels: IndexedTilePixels;
121
+ index: number;
122
+ tileIndex: number;
123
+ handleExportFrame: ExportFrameMode;
124
+ lockFrame: boolean;
125
+ invertPalette: boolean;
126
+ colorData: BWPalette;
127
+ }) => RGBValue;
128
+
129
+ declare const tileIndexIsPartOfFrame: (tileIndex: number, handleExportFrame?: ExportFrameMode) => boolean;
130
+
131
+ export { type BWPalette, BlendMode, type ChangedTile, type Channel, type Channels, Decoder, ExportFrameMode, type IndexedTilePixels, RGBNDecoder, type RGBNPalette, type RGBNTiles, type RGBValue, type ScaledCanvasSize, type SourceCanvases, blendModeNewName, decodeTile, getRGBValue, tileIndexIsPartOfFrame };