Skip to content

Commit

Permalink
Merge pull request #4756 from TakumaKira/main
Browse files Browse the repository at this point in the history
Allow drawing point with large scale and small strokeWeight.
  • Loading branch information
lmccart authored Mar 13, 2021
2 parents 2fdd4c9 + 2dec04a commit 39b4fd7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
12 changes: 3 additions & 9 deletions src/core/p5.Renderer2D.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,17 +568,11 @@ p5.Renderer2D.prototype.point = function(x, y) {
}
const s = this._getStroke();
const f = this._getFill();
x = Math.round(x);
y = Math.round(y);
// swapping fill color to stroke and back after for correct point rendering
this._setFill(s);
if (ctx.lineWidth > 1) {
ctx.beginPath();
ctx.arc(x, y, ctx.lineWidth / 2, 0, constants.TWO_PI, false);
ctx.fill();
} else {
ctx.fillRect(x, y, 1, 1);
}
ctx.beginPath();
ctx.arc(x, y, ctx.lineWidth / 2, 0, constants.TWO_PI, false);
ctx.fill();
this._setFill(f);
};

Expand Down
2 changes: 1 addition & 1 deletion test/unit/core/structure.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ suite('Structure', function() {
myp5.background(0);
myp5.stroke(255);
myp5.point(10, 10);
if (myp5.get(10, 10)[0] !== 255) {
if (myp5.get(10, 10)[0] === 0) {
reject(new Error("Drawing matrix doesn't appear to be reset"));
}
myp5.rotate(10);
Expand Down

0 comments on commit 39b4fd7

Please sign in to comment.