Skip to content

Commit

Permalink
refactor: calc aspectRatio
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Dej <[email protected]>
  • Loading branch information
meteyou committed Dec 25, 2023
1 parent 4292161 commit 28dc0ea
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/components/webcams/streamers/MjpegstreamerAdaptive.vue
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ export default class MjpegstreamerAdaptive extends Mixins(BaseMixin, WebcamMixin
const ctx = canvas.getContext('2d')
const frame: any = await this.loadImage(url.toString())
if (this.rotate) this.aspectRatio = frame.naturalHeight / frame.naturalWidth
else this.aspectRatio = frame.naturalWidth / frame.naturalHeight
this.aspectRatio = frame.naturalWidth / frame.naturalHeight
if (this.rotate) this.aspectRatio = 1 / this.aspectRatio
// set canvas sizes
canvas.width = canvas.clientWidth
canvas.height = canvas.clientWidth * (this.aspectRatio ?? 1.33)
canvas.height = canvas.clientWidth / this.aspectRatio
if (this.rotate) {
const scale = canvas.height / frame.width
Expand Down

0 comments on commit 28dc0ea

Please sign in to comment.