gb-image-decoder 0.0.3 → 0.1.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.
Files changed (2) hide show
  1. package/README.md +80 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,2 +1,82 @@
1
1
  # GameBoy-Tile format Image Decoders
2
2
 
3
+ This package renders GameBoy-encoded images to a canvas element.
4
+
5
+ You may need the [gbp-decode package](https://npmjs.com/gbp-decode) to decode various sources.
6
+ Or you may want to use the [arduino-gameboy-printer-emulator](https://github.com/mofosyne/arduino-gameboy-printer-emulator).
7
+ There are a lot more similar projects for aquiring raw tile data.
8
+
9
+ ## Usage
10
+ Import within your Project
11
+ ```typescript
12
+ import { RGBNDecoder, Decoder, RGBNTiles } from 'gb-image-decoder';
13
+ ```
14
+
15
+ Have a canvas element inside your DOM
16
+ ```typescript
17
+ const myCanvas: HTMLCanvasElement = document.createElement('canvas');
18
+ ```
19
+
20
+ ### For monochrome images:
21
+
22
+ Have a set of tiles (each string represents a 8x8 tile)
23
+ ```typescript
24
+ // For classic monochrome images:
25
+ const myTiles: string[] = [ // need 360 of these for a 160x144 image
26
+ '7D FF 0A FF 7D FF FF FF 5F FF BB FF 5D FF FF FF', '75 FF A2 FF 44 FF FF FF 5D FF FF FF FF FF FF FF', '55 FF 1F FF 57 FF FF FF 7D FF FF FF FF FF FF FF', '77 FF FD FF 57 FF FF FF 75 FF FF FF DF FF FF FF',
27
+ ];
28
+ ```
29
+
30
+ Have a palette for your monochrome image
31
+ ```typescript
32
+ const monoPalette = ['#ffffff', '#aaaaaa', '#555555', '#000000'];
33
+ ```
34
+
35
+ Initialize the decoder:
36
+ ```typescript
37
+ const decoder = new Decoder();
38
+ decoder.update({
39
+ canvas: myCanvas,
40
+ tiles: myTiles,
41
+ palette: monoPalette,
42
+ lockFrame: false,
43
+ invertPalette: false,
44
+ });
45
+ ```
46
+
47
+ ### For RGBN images:
48
+ RGB(N) Images can contain any of the channels. All channels are optional, but the r,g,b channels are recommended.
49
+
50
+ Your image needs a set of RGBN tiles:
51
+ ```typescript
52
+ // For RGBN images
53
+ const myTilesRGBN: RGBNTiles = { // need 360 of each for a 160x144 image
54
+ r: ['7D FF 0A FF 7D FF FF FF 5F FF BB FF 5D FF FF FF', '75 FF A2 FF 44 FF FF FF 5D FF FF FF FF FF FF FF', '55 FF 1F FF 57 FF FF FF 7D FF FF FF FF FF FF FF', '77 FF FD FF 57 FF FF FF 75 FF FF FF DF FF FF FF'],
55
+ g: ['7F FF BF FF FF FF FF FF DF FF FF FF FF FF FF FF', 'A2 D5 FC C3 4C D3 FE C1 D8 E4 ED F2 FF F1 DB FC', 'EA 55 83 FC 48 F5 07 F8 A4 53 A8 07 A3 5C FE 01', 'FF 3F FF 3F FF 3F 7F BF FF 3F FF 7F 7D FF FF FF'],
56
+ b: ['F7 FF A3 FF FF FF FF FF FF FF FF FF FF FF FF FF', '0A F5 80 FF 40 FF F1 FE FB FD F0 FF 52 FD E1 FE', '88 77 40 BF 2A D5 18 EF 88 77 04 FB AA 55 17 E8', 'A0 5F 51 AE AA 55 54 AB AA 55 05 FA AA 55 67 98'],
57
+ // neutral image is optional
58
+ };
59
+ ```
60
+
61
+ For RGBN there is a default blend palette available:
62
+ ```typescript
63
+ import { defaultPalette as rgbnPalette } from 'gb-image-decoder';
64
+ ```
65
+
66
+ Initialize the decoder:
67
+ ```typescript
68
+ const decoder = new RGBNDecoder();
69
+ decoder.update({
70
+ canvas: myCanvas,
71
+ tiles: myTilesRGBN,
72
+ palette: rgbnPalette,
73
+ lockFrame: false,
74
+ });
75
+ ```
76
+
77
+ ## ToDos
78
+ * improve docs
79
+ * tests
80
+
81
+ ## License: MIT
82
+ [LICENSE](./LICENSE)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gb-image-decoder",
3
- "version": "0.0.3",
3
+ "version": "0.1.0",
4
4
  "description": "Decoder classes for GameBoy images",
5
5
  "repository": "",
6
6
  "license": "MIT",