* Loads the current value of each pixel in the image into the `img.pixels` * array. * * `img.loadPixels()` must be called before reading or modifying pixel * values. * * @example * function setup() { * createCanvas(100, 100); * * background(200); * * // Crea
()
| 172 | * } |
| 173 | */ |
| 174 | loadPixels() { |
| 175 | // Renderer2D.prototype.loadPixels.call(this); |
| 176 | const pixelsState = this._pixelsState; |
| 177 | const pd = this._pixelDensity; |
| 178 | const w = this.width * pd; |
| 179 | const h = this.height * pd; |
| 180 | const imageData = this.drawingContext.getImageData(0, 0, w, h); |
| 181 | // @todo this should actually set pixels per object, so diff buffers can |
| 182 | // have diff pixel arrays. |
| 183 | pixelsState.imageData = imageData; |
| 184 | this.pixels = pixelsState.pixels = imageData.data; |
| 185 | this.setModified(true); |
| 186 | } |
| 187 | |
| 188 | /** |
| 189 | * Updates the canvas with the RGBA values in the |
no test coverage detected