Skip to content

Commit

Permalink
change the get() function to retain value of pd and not streching the…
Browse files Browse the repository at this point in the history
… canvas
  • Loading branch information
Gaurav-1306 committed Oct 6, 2023
1 parent dfb27a3 commit 66e1377
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/empty-example/sketch.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function setup() {
// put setup code here

}

function draw() {
// put drawing code here

}
1 change: 1 addition & 0 deletions src/core/p5.Renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ class Renderer extends p5.Element {
}

const region = new p5.Image(w, h);
region._pixelDensity = pd;
region.canvas
.getContext('2d')
.drawImage(canvas, x, y, w * pd, h * pd, 0, 0, w, h);
Expand Down
4 changes: 2 additions & 2 deletions src/image/p5.Image.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ p5.Image = class {
this._pixelDensity = density;

// Adjust canvas dimensions based on pixel density
this.canvas.width = this.width * density;
this.canvas.height = this.height * density;
this.width /= density;
this.height /= density;

return this; // Return the image instance for chaining if needed
} else {
Expand Down

0 comments on commit 66e1377

Please sign in to comment.