Skip to content
Open
Show file tree
Hide file tree
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
16 changes: 10 additions & 6 deletions src/shape/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,16 @@ function attributes(p5, fn){
* </code>
* </div>
*/
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;
Expand Down
21 changes: 21 additions & 0 deletions test/manual-test-examples/noSmooth/canvas-2d.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Test noSmooth on main canvas 2D</title>
<script src="../../../lib/p5.js"></script>
<script>
function setup() {
createCanvas(100, 100);

try {
noSmooth();
console.log("✔ Main Canvas: noSmooth OK");
} catch (e) {
console.error("❌ Main Canvas: noSmooth ERROR", e);
}
}
</script>
</head>
<body></body>
</html>
22 changes: 22 additions & 0 deletions test/manual-test-examples/noSmooth/graphics-webgl.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Test noSmooth on p5.Graphics WebGL</title>
<script src="../../../lib/p5.js"></script> <script>
function setup() {
createCanvas(100, 100, WEBGL);

const g = createGraphics(100, 100, WEBGL);

try {
g.noSmooth();
console.log("✔ WebGL p5.Graphics: noSmooth OK");
} catch (e) {
console.error("❌ WebGL p5.Graphics: noSmooth ERROR", e);
}
}
</script>
</head>
<body></body>
</html>
Loading