You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Welcome! 👋 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, please make sure to fill out the inputs in the issue forms. Thank you!
The CSS border on canvas does have this side effect; sometimes using box-sizing: border-box along with borders can be helpful. Another solution to this is to place the canvas inside a div, for example as in:
function setup() {
let container = createDiv();
container.id("sketch-container");
canvas = createCanvas(400, 400);
canvas.parent(container);
}
function draw() {
background(0);
rect(mouseX, mouseY, 50, 50)
}
And in the CSS:
#sketch-container {
display: inline-block;
border: 20px darkslategrey groove;
}
Updating the functionality would be a breaking change, so if someone added a border around the canvas and artificially changed mouseX, their application would break, so I'd be hesitant to fix this intuitive functionality. Maybe it could be fixed in p5.js 2.0 if its still accepting proposals.
I haven't looked into it much, but we could manually take into account the width of the border / padding to ensure mouseX lines up with the canvas's content. I'm willing to contribute if we decide to fix this bug.
Most appropriate sub-area of p5.js?
p5.js version
1.9.4
Web browser and version
130.0.6723.117 (Official Build) (64-bit) (cohort: Stable)
Operating system
Steps to reproduce this
Steps:
Snippet:
The text was updated successfully, but these errors were encountered: