Skip to content

Commit

Permalink
Add back global 'pixels', fixes #7482
Browse files Browse the repository at this point in the history
  • Loading branch information
limzykenneth committed Jan 20, 2025
1 parent fd39484 commit f6c8fcf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/core/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ class p5 {
}
}

get pixels(){
return this._renderer.pixels;
}

static registerAddon(addon) {
const lifecycles = {};
addon(p5, p5.prototype, lifecycles);
Expand Down
12 changes: 6 additions & 6 deletions src/core/rendering.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ function rendering(p5, fn){
* @param {HTMLCanvasElement} [canvas]
* @return {p5.Renderer}
*/
p5.prototype.createCanvas = function (w, h, renderer, ...args) {
fn.createCanvas = function (w, h, renderer, ...args) {
// p5._validateParameters('createCanvas', arguments);
//optional: renderer, otherwise defaults to p2d

Expand Down Expand Up @@ -239,7 +239,7 @@ function rendering(p5, fn){
* </code>
* </div>
*/
p5.prototype.resizeCanvas = function (w, h, noRedraw) {
fn.resizeCanvas = function (w, h, noRedraw) {
// p5._validateParameters('resizeCanvas', arguments);
if (this._renderer) {
// Make sure width and height are updated before the renderer resizes so
Expand Down Expand Up @@ -274,7 +274,7 @@ function rendering(p5, fn){
* </code>
* </div>
*/
p5.prototype.noCanvas = function () {
fn.noCanvas = function () {
if (this.canvas) {
this.canvas.parentNode.removeChild(this.canvas);
}
Expand Down Expand Up @@ -392,7 +392,7 @@ function rendering(p5, fn){
* @param {HTMLCanvasElement} [canvas]
* @return {p5.Graphics}
*/
p5.prototype.createGraphics = function (w, h, ...args) {
fn.createGraphics = function (w, h, ...args) {
/**
* args[0] is expected to be renderer
* args[1] is expected to be canvas
Expand Down Expand Up @@ -541,7 +541,7 @@ function rendering(p5, fn){
* </code>
* </div>
*/
p5.prototype.createFramebuffer = function (options) {
fn.createFramebuffer = function (options) {
return new Framebuffer(this._renderer, options);
};

Expand Down Expand Up @@ -625,7 +625,7 @@ function rendering(p5, fn){
* </code>
* </div>
*/
p5.prototype.clearDepth = function (depth) {
fn.clearDepth = function (depth) {
this._assert3d('clearDepth');
this._renderer.clearDepth(depth);
};
Expand Down

0 comments on commit f6c8fcf

Please sign in to comment.