fix: fromScreen not using viewport scale, mousePos() not working with letterbox/stretch
Description
Issues or related
- Related Issue #
- Closes #325
Additionally, you don't want to divide each time, it is better to store 1 / factor and multiply instead.
So scale is fine now, it's stretch that is bugged. If letterbox: true then it works since the canvas's aspect ratio is as specified. stretch makes it not be as specified, so it gets off.
kaplay({
scale: 3,
width: 20,
height: 40,
stretch: true
});
const x = add([
anchor("center"),
circle(3),
color(RED),
pos(),
]);
getTreeRoot().use(pos());
onMouseMove(pos => {
x.pos = getTreeRoot().fromScreen(pos);
});
Yeah, when stretch is used, you no longer have a uniform scale. You need a vec2 in that case.
So scale is fine now, it's stretch that is bugged. If
letterbox: truethen it works since the canvas's aspect ratio is as specified.stretchmakes it not be as specified, so it gets off.kaplay({ scale: 3, width: 20, height: 40, stretch: true }); const x = add([ anchor("center"), circle(3), color(RED), pos(), ]); getTreeRoot().use(pos()); onMouseMove(pos => { x.pos = getTreeRoot().fromScreen(pos); });
The question is if there's an user case using only Stretch without letterbox
resolved conflicts in commit 894d9df6d65baa497d017fb09db200cb39066eae
no idea for fail should of worked properly