| 99 | const sup = "⁰¹²³⁴⁵⁶⁷⁸⁹ᵃᵇᶜᵈᵉᶠ"; |
| 100 | |
| 101 | export function testImageReadableMatrix(img: Bitmap) { |
| 102 | const len = img.data.length / 4; |
| 103 | |
| 104 | const rMatrix = []; |
| 105 | let line = []; |
| 106 | |
| 107 | for (let i = 0; i < len; i++) { |
| 108 | const pix = img.data |
| 109 | .readUint32BE(i * 4) |
| 110 | .toString(16) |
| 111 | .toUpperCase() |
| 112 | .padStart(8, "0"); |
| 113 | |
| 114 | line.push( |
| 115 | pix.replace(/(..)(..)(..)(.)(.)/, (sel, r, g, b, a1, a2) => { |
| 116 | const a = sup[parseInt(a1, 16)]! + sup[parseInt(a2, 16)]!; |
| 117 | return r + "-" + g + "-" + b + a; |
| 118 | }), |
| 119 | ); |
| 120 | if (i > 0 && (i + 1) % img.width === 0) { |
| 121 | rMatrix.push(line.join(" ")); |
| 122 | line = []; |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | return rMatrix.join("\n"); |
| 127 | } |
| 128 | |
| 129 | /** Helps to debug image data */ |
| 130 | export function testImgToStr(testImage: Bitmap) { |