(pixels)
| 1229 | } |
| 1230 | |
| 1231 | setPixels(pixels) { |
| 1232 | if (!pixels || typeof pixels.length !== "number") { |
| 1233 | throw new Error("Ungültige Pixelwerte für den Zeichenblock."); |
| 1234 | } |
| 1235 | if (pixels.length !== this.values.length) { |
| 1236 | throw new Error( |
| 1237 | `Erwartete ${this.values.length} Pixel, erhielt aber ${pixels.length}.`, |
| 1238 | ); |
| 1239 | } |
| 1240 | for (let i = 0; i < this.values.length; i += 1) { |
| 1241 | const value = clamp(Number(pixels[i]) || 0, 0, 1); |
| 1242 | if (this.values[i] !== value) { |
| 1243 | this.values[i] = value; |
| 1244 | this.updateCellVisual(i); |
| 1245 | } |
| 1246 | } |
| 1247 | if (typeof this.onChange === "function") { |
| 1248 | this.onChange(); |
| 1249 | } |
| 1250 | } |
| 1251 | |
| 1252 | clear() { |
| 1253 | this.values.fill(0); |
no test coverage detected