MCPcopy Index your code
hub / github.com/processing/p5.js / loadPixels

Method loadPixels

src/webgl/p5.Framebuffer.js:1008–1024  ·  view source on GitHub ↗

* Loads the current value of each pixel in the framebuffer into its * pixels array. * * `myBuffer.loadPixels()` must be called before reading from or writing to * myBuffer.pixels . * * @example * function

()

Source from the content-addressed store, hash-verified

1006 * }
1007 */
1008 loadPixels() {
1009 this._update('colorTexture');
1010 const result = this.renderer.readFramebufferPixels(this);
1011
1012 // Check if renderer returned a Promise (WebGPU) or data directly (WebGL)
1013 if (result && typeof result.then === 'function') {
1014 // WebGPU async case - return Promise
1015 return result.then(pixels => {
1016 this.pixels = pixels;
1017 return pixels;
1018 });
1019 } else {
1020 // WebGL sync case - assign directly
1021 this.pixels = result;
1022 return result;
1023 }
1024 }
1025
1026 /**
1027 * Gets a pixel or a region of pixels from the framebuffer.

Callers

nothing calls this directly

Calls 2

_updateMethod · 0.95
readFramebufferPixelsMethod · 0.45

Tested by

no test coverage detected