Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/core/p5.Renderer3D.js
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,35 @@
}

background(...args) {
const a0 = args[0];

const isImageLike =
a0 instanceof p5.Image ||

Check failure on line 734 in src/core/p5.Renderer3D.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, chrome)

test/unit/webgl/p5.Framebuffer.js > p5.Framebuffer > formats and channels > framebuffers work with WebGL 1, unsigned-byte rgb unsigned-int depth

ReferenceError: p5 is not defined ❯ RendererGL.background src/core/p5.Renderer3D.js:734:21 ❯ fn.background src/color/setting.js:671:20 ❯ p5.background src/core/friendly_errors/param_validator.js:583:23 ❯ test/unit/webgl/p5.Framebuffer.js:65:18 ❯ Framebuffer.draw src/webgl/p5.Framebuffer.js:999:5 ❯ test/unit/webgl/p5.Framebuffer.js:64:15

Check failure on line 734 in src/core/p5.Renderer3D.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, chrome)

test/unit/webgl/p5.Framebuffer.js > p5.Framebuffer > formats and channels > framebuffers work with WebGL 1, unsigned-byte rgb no depth antialiased

ReferenceError: p5 is not defined ❯ RendererGL.background src/core/p5.Renderer3D.js:734:21 ❯ fn.background src/color/setting.js:671:20 ❯ p5.background src/core/friendly_errors/param_validator.js:583:23 ❯ test/unit/webgl/p5.Framebuffer.js:65:18 ❯ Framebuffer.draw src/webgl/p5.Framebuffer.js:999:5 ❯ test/unit/webgl/p5.Framebuffer.js:64:15

Check failure on line 734 in src/core/p5.Renderer3D.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, chrome)

test/unit/webgl/p5.Framebuffer.js > p5.Framebuffer > formats and channels > framebuffers work with WebGL 1, unsigned-byte rgb float depth antialiased

ReferenceError: p5 is not defined ❯ RendererGL.background src/core/p5.Renderer3D.js:734:21 ❯ fn.background src/color/setting.js:671:20 ❯ p5.background src/core/friendly_errors/param_validator.js:583:23 ❯ test/unit/webgl/p5.Framebuffer.js:65:18 ❯ Framebuffer.draw src/webgl/p5.Framebuffer.js:999:5 ❯ test/unit/webgl/p5.Framebuffer.js:64:15

Check failure on line 734 in src/core/p5.Renderer3D.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, chrome)

test/unit/webgl/p5.Framebuffer.js > p5.Framebuffer > formats and channels > framebuffers work with WebGL 1, unsigned-byte rgb unsigned-int depth antialiased

ReferenceError: p5 is not defined ❯ RendererGL.background src/core/p5.Renderer3D.js:734:21 ❯ fn.background src/color/setting.js:671:20 ❯ p5.background src/core/friendly_errors/param_validator.js:583:23 ❯ test/unit/webgl/p5.Framebuffer.js:65:18 ❯ Framebuffer.draw src/webgl/p5.Framebuffer.js:999:5 ❯ test/unit/webgl/p5.Framebuffer.js:64:15

Check failure on line 734 in src/core/p5.Renderer3D.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, chrome)

test/unit/webgl/p5.Framebuffer.js > p5.Framebuffer > formats and channels > framebuffers work with WebGL 1, unsigned-byte rgba no depth

ReferenceError: p5 is not defined ❯ RendererGL.background src/core/p5.Renderer3D.js:734:21 ❯ fn.background src/color/setting.js:671:20 ❯ p5.background src/core/friendly_errors/param_validator.js:583:23 ❯ test/unit/webgl/p5.Framebuffer.js:65:18 ❯ Framebuffer.draw src/webgl/p5.Framebuffer.js:999:5 ❯ test/unit/webgl/p5.Framebuffer.js:64:15

Check failure on line 734 in src/core/p5.Renderer3D.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, chrome)

test/unit/webgl/p5.Framebuffer.js > p5.Framebuffer > formats and channels > framebuffers work with WebGL 1, unsigned-byte rgba float depth

ReferenceError: p5 is not defined ❯ RendererGL.background src/core/p5.Renderer3D.js:734:21 ❯ fn.background src/color/setting.js:671:20 ❯ p5.background src/core/friendly_errors/param_validator.js:583:23 ❯ test/unit/webgl/p5.Framebuffer.js:65:18 ❯ Framebuffer.draw src/webgl/p5.Framebuffer.js:999:5 ❯ test/unit/webgl/p5.Framebuffer.js:64:15

Check failure on line 734 in src/core/p5.Renderer3D.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, chrome)

test/unit/webgl/p5.Framebuffer.js > p5.Framebuffer > formats and channels > framebuffers work with WebGL 1, unsigned-byte rgba unsigned-int depth

ReferenceError: p5 is not defined ❯ RendererGL.background src/core/p5.Renderer3D.js:734:21 ❯ fn.background src/color/setting.js:671:20 ❯ p5.background src/core/friendly_errors/param_validator.js:583:23 ❯ test/unit/webgl/p5.Framebuffer.js:65:18 ❯ Framebuffer.draw src/webgl/p5.Framebuffer.js:999:5 ❯ test/unit/webgl/p5.Framebuffer.js:64:15

Check failure on line 734 in src/core/p5.Renderer3D.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, chrome)

test/unit/webgl/p5.Framebuffer.js > p5.Framebuffer > formats and channels > framebuffers work with WebGL 1, unsigned-byte rgba no depth antialiased

ReferenceError: p5 is not defined ❯ RendererGL.background src/core/p5.Renderer3D.js:734:21 ❯ fn.background src/color/setting.js:671:20 ❯ p5.background src/core/friendly_errors/param_validator.js:583:23 ❯ test/unit/webgl/p5.Framebuffer.js:65:18 ❯ Framebuffer.draw src/webgl/p5.Framebuffer.js:999:5 ❯ test/unit/webgl/p5.Framebuffer.js:64:15

Check failure on line 734 in src/core/p5.Renderer3D.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, chrome)

test/unit/webgl/p5.Framebuffer.js > p5.Framebuffer > formats and channels > framebuffers work with WebGL 1, unsigned-byte rgba float depth antialiased

ReferenceError: p5 is not defined ❯ RendererGL.background src/core/p5.Renderer3D.js:734:21 ❯ fn.background src/color/setting.js:671:20 ❯ p5.background src/core/friendly_errors/param_validator.js:583:23 ❯ test/unit/webgl/p5.Framebuffer.js:65:18 ❯ Framebuffer.draw src/webgl/p5.Framebuffer.js:999:5 ❯ test/unit/webgl/p5.Framebuffer.js:64:15

Check failure on line 734 in src/core/p5.Renderer3D.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, chrome)

test/unit/webgl/p5.Framebuffer.js > p5.Framebuffer > formats and channels > framebuffers work with WebGL 1, unsigned-byte rgba unsigned-int depth antialiased

ReferenceError: p5 is not defined ❯ RendererGL.background src/core/p5.Renderer3D.js:734:21 ❯ fn.background src/color/setting.js:671:20 ❯ p5.background src/core/friendly_errors/param_validator.js:583:23 ❯ test/unit/webgl/p5.Framebuffer.js:65:18 ❯ Framebuffer.draw src/webgl/p5.Framebuffer.js:999:5 ❯ test/unit/webgl/p5.Framebuffer.js:64:15
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, tests are failing currently because p5 isn't globally available in p5 2.0 so that we can create smaller, more modular builds without importing everything.

Maybe rather than checking if something is an instance of a class, we use duck typing and check to see if it has the properties of an image, graphics, or media element? I think that would imply checking that a0 is not undefined and it has width, height, and canvas properties.

a0 instanceof p5.Graphics ||
a0 instanceof p5.MediaElement ||
(typeof HTMLImageElement !== 'undefined' && a0 instanceof HTMLImageElement) ||
(typeof HTMLVideoElement !== 'undefined' && a0 instanceof HTMLVideoElement) ||
(typeof HTMLCanvasElement !== 'undefined' && a0 instanceof HTMLCanvasElement);

// WEBGL / 3D: support background(image)
if (args.length > 0 && isImageLike) {
this._pInst.clear();
this._pInst.push();
this._pInst.resetMatrix();
this._pInst.imageMode(constants.CORNER);
this._pInst.image(
a0,
-this._pInst.width / 2,
-this._pInst.height / 2,
this._pInst.width,
this._pInst.height
);

this._pInst.pop();
return;
}

// Default: background(color)
const _col = this._pInst.color(...args);
this.clear(..._col._getRGBA());
}
Expand Down
Loading