MCPcopy
hub / github.com/processing/p5.js / loadPixels

Method loadPixels

src/image/p5.Image.js:174–186  ·  view source on GitHub ↗

* 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

()

Source from the content-addressed store, hash-verified

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

Callers 15

resizeMethod · 0.95
constructorMethod · 0.45
drawFunction · 0.45
drawFunction · 0.45
drawFunction · 0.45
drawFunction · 0.45
drawFunction · 0.45
setupFunction · 0.45
p5.MediaElement.jsFile · 0.45
p5.Image.jsFile · 0.45
testImageRenderFunction · 0.45
checkTintFunction · 0.45

Calls 1

setModifiedMethod · 0.95

Tested by

no test coverage detected