Normalize the size of the camera frame container from window size.

If the window is smaller than the camera resolution, then we should
scale down the container size accordingly.
This commit is contained in:
Fabio Manganiello 2023-08-07 00:38:19 +02:00
parent 8b245a1618
commit 5184543a3e
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -86,8 +86,21 @@ export default {
onSizeChanged() {
const degToRad = (deg) => (deg * Math.PI)/180
const rot = degToRad(this.params.rotate)
this.$refs.frameContainer.style.width = Math.round(this.params.scale_x * Math.abs(this.params.resolution[0] * Math.cos(rot) + this.params.resolution[1] * Math.sin(rot))) + 'px'
this.$refs.frameContainer.style.height = Math.round(this.params.scale_y * Math.abs(this.params.resolution[0] * Math.sin(rot) + this.params.resolution[1] * Math.cos(rot))) + 'px'
let width = Math.round(this.params.scale_x * Math.abs(this.params.resolution[0] * Math.cos(rot) + this.params.resolution[1] * Math.sin(rot)))
let height = Math.round(this.params.scale_y * Math.abs(this.params.resolution[0] * Math.sin(rot) + this.params.resolution[1] * Math.cos(rot)))
if (width > window.innerWidth) {
height = Math.round(height * (window.innerWidth / width))
width = window.innerWidth
}
if (height > window.innerHeight) {
width = Math.round(width * (window.innerHeight / height))
height = window.innerHeight
}
this.$refs.frameContainer.style.width = `${width}px`
this.$refs.frameContainer.style.height = `${height}px`
},
onFpsChanged() {},