* @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)
| 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 |
no test coverage detected