| 20 | } |
| 21 | |
| 22 | class PNGDecoder extends PNG { |
| 23 | constructor(args) { |
| 24 | super(args); |
| 25 | this.pixels = []; |
| 26 | } |
| 27 | |
| 28 | decodeToPixels() { |
| 29 | return new Promise((resolve) => { |
| 30 | this.decode((pixels) => { |
| 31 | this.pixels = pixels; |
| 32 | resolve(); |
| 33 | }); |
| 34 | }); |
| 35 | } |
| 36 | |
| 37 | getImageData(x, y, w, h) { |
| 38 | const {pixels} = this; |
| 39 | const len = w * h * 4; |
| 40 | const startIndex = x * 4 + y * (w * 4); |
| 41 | |
| 42 | return {data: pixels.slice(startIndex, startIndex + len)}; |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | const PUZZLE_GAP = 8; |
| 47 | const PUZZLE_PAD = 10; |
nothing calls this directly
no outgoing calls
no test coverage detected