Skip to content

Commit

Permalink
Fit resolutions to less than 2k x 2k (#1065)
Browse files Browse the repository at this point in the history
* Fit resolutions to less than 2k x 2k

* Integer resolutions

* Scale mouse clicks

* Move stream maxResolution logic to getDimensions
  • Loading branch information
iterion committed Nov 14, 2023
1 parent 381d0b3 commit 2519712
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 24 deletions.
21 changes: 0 additions & 21 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions src/hooks/useSetupEngineManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,14 @@ export function useSetupEngineManager(
}

function getDimensions(streamWidth?: number, streamHeight?: number) {
const maxResolution = 2000
const width = streamWidth ? streamWidth : 0
const quadWidth = Math.round(width / 4) * 4
const height = streamHeight ? streamHeight : 0
const quadHeight = Math.round(height / 4) * 4
const ratio = Math.min(
Math.min(maxResolution / width, maxResolution / height),
1.0
)
const quadWidth = Math.round((width * ratio) / 4) * 4
const quadHeight = Math.round((height * ratio) / 4) * 4
return { width: quadWidth, height: quadHeight }
}
5 changes: 4 additions & 1 deletion src/lang/std/engineConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,10 @@ export class EngineCommandManager {

// If we already have an engine connection, just need to resize the stream.
if (this.engineConnection) {
this.handleResize({ streamWidth: width, streamHeight: height })
this.handleResize({
streamWidth: width,
streamHeight: height,
})
return
}

Expand Down

1 comment on commit 2519712

@vercel
Copy link

@vercel vercel bot commented on 2519712 Nov 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.