diff --git a/src/shape/attributes.js b/src/shape/attributes.js index 5669c5d32e..c0a80cfa23 100644 --- a/src/shape/attributes.js +++ b/src/shape/attributes.js @@ -167,12 +167,16 @@ function attributes(p5, fn){ * * */ - fn.noSmooth = function() { - if (!this._renderer.isP3D) { - if ('imageSmoothingEnabled' in this.drawingContext) { - this.drawingContext.imageSmoothingEnabled = false; - } - } else { + fn.noSmooth = function () { + if (this._renderer && typeof this._renderer.setSmoothing === 'function') { + this._renderer.setSmoothing(false); + } else if ( + !this._renderer.isP3D && + this.drawingContext && + 'imageSmoothingEnabled' in this.drawingContext + ) { + this.drawingContext.imageSmoothingEnabled = false; + } else if (typeof this.setAttributes === 'function') { this.setAttributes('antialias', false); } return this; diff --git a/test/manual-test-examples/noSmooth/canvas-2d.html b/test/manual-test-examples/noSmooth/canvas-2d.html new file mode 100644 index 0000000000..fff6859f0e --- /dev/null +++ b/test/manual-test-examples/noSmooth/canvas-2d.html @@ -0,0 +1,21 @@ + + + + + Test noSmooth on main canvas 2D + + + + + diff --git a/test/manual-test-examples/noSmooth/graphics-webgl.html b/test/manual-test-examples/noSmooth/graphics-webgl.html new file mode 100644 index 0000000000..78aeab006e --- /dev/null +++ b/test/manual-test-examples/noSmooth/graphics-webgl.html @@ -0,0 +1,22 @@ + + + + + Test noSmooth on p5.Graphics WebGL + + + +