Disabling video auto scaling requires workaround
See original GitHub issueOS platform / Browser
Windows 10, Chrome 105
melonJS version
v13.0.0
Bug description
Video always auto scale, even if settings.scale != 'auto'
When not specified, setting.scaleMethod
defaults to fit
, forcing settings.autoScale
to true
((anything || true) == true
)
https://github.com/melonjs/melonJS/blob/313af5c746d25d8d0d33986bf631f3e18843e857/src/video/video.js#L237-L238
Setting setting.scale
to a value bigger than 1 and changing setting.scaleMethod
to an empty string (or any string that doesn’t math the if
above) still doesn’t work because, for some reason, the canvas element comes with it’s width/height set to width * scale
/height * scale
instead of just width
/height
and without style="width:...;height:...;"
, so everything drawn in the canvas is smaller than it should.
Steps to reproduce the bug
video.init(64, 64, {
parent: 'screen',
scale: 8
})
Workaround
The only way to disable auto scaling and make the scaling work as intended is to set setting.scale
to 1
and then call video.scale()
with the desired scale size
video.init(64, 64, {
parent: 'screen',
scale: 1, // Must be 1 to force canvas size to the correct width/height (64x64 in this case)
scaleMethod: '' // Any invalid string value works
})
video.scale(8, 8) // Scale canvas to the intended size
Issue Analytics
- State:
- Created a year ago
- Comments:7 (5 by maintainers)
Top GitHub Comments
😃😃😃😃
yes, we had some refactoring going out around the renderer(s) to align both the canvas and WebGL one.
But cool then, I’ll close back this one 😃