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

Method get

src/webgl/p5.Framebuffer.js:1061–1088  ·  view source on GitHub ↗

* @param {Number} x * @param {Number} y * @return {Number[]} color of the pixel at `(x, y)` as an array of color values `[R, G, B, A]`.

(x, y, w, h)

Source from the content-addressed store, hash-verified

1059 * @return {Number[]} color of the pixel at `(x, y)` as an array of color values `[R, G, B, A]`.
1060 */
1061 get(x, y, w, h) {
1062 this._update('colorTexture');
1063 // p5._validateParameters('p5.Framebuffer.get', arguments);
1064
1065 if (x === undefined && y === undefined) {
1066 x = 0;
1067 y = 0;
1068 w = this.width;
1069 h = this.height;
1070 } else if (w === undefined && h === undefined) {
1071 if (x < 0 || y < 0 || x >= this.width || y >= this.height) {
1072 console.warn(
1073 'The x and y values passed to p5.Framebuffer.get are outside of its range and will be clamped.'
1074 );
1075 x = constrain(x, 0, this.width - 1);
1076 y = constrain(y, 0, this.height - 1);
1077 }
1078
1079 return this.renderer.readFramebufferPixel(this, x * this.density, y * this.density);
1080 }
1081
1082 x = constrain(x, 0, this.width - 1);
1083 y = constrain(y, 0, this.height - 1);
1084 w = constrain(w, 1, this.width - x);
1085 h = constrain(h, 1, this.height - y);
1086
1087 return this.renderer.readFramebufferRegion(this, x, y, w, h);
1088 }
1089
1090 /**
1091 * Updates the framebuffer with the RGBA values in the

Callers 5

_tesselateShapeMethod · 0.45
generateExpressionFunction · 0.45
_edgesToVerticesMethod · 0.45
textFunction · 0.45
_accumulateMipLevelMethod · 0.45

Calls 4

_updateMethod · 0.95
constrainFunction · 0.85
readFramebufferPixelMethod · 0.45
readFramebufferRegionMethod · 0.45

Tested by

no test coverage detected