Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Disable automatic resizing of the canvas #1896

Closed
Code-Chops opened this issue Dec 17, 2021 · 5 comments
Closed

[FEATURE] Disable automatic resizing of the canvas #1896

Code-Chops opened this issue Dec 17, 2021 · 5 comments

Comments

@Code-Chops
Copy link

At the moment it's not possible to disable automatic resizing of the canvas. Besides that there is a bug in the automatic resizing, I don't want the functionality at all for my project.

Would it be a good idea to add a parameter 'IgnoreResizing' / 'DisableAutomaticResizing' to the canvas? Setting the value to 'true' will not load the SizeWatcher JavasScript at all:

sizeWatcher = await SizeWatcherInterop.ImportAsync(JS, htmlCanvas, OnSizeChanged);

I could add the functionality if you are open for it? Thanks in advance!

@robloo
Copy link

robloo commented Dec 18, 2021

AutoResize might be a better property name. Usually names are such that true is the enabled state.

@Code-Chops Code-Chops changed the title [FEATURE] [FEATURE] Disable automatic resizing of the canvas Dec 19, 2021
@mgood7123
Copy link
Contributor

why would you want to disable automatic resizing?

@ViRuSTriNiTy
Copy link

why would you want to disable automatic resizing?

Because sometimes you have the requirement of a fixed width and height for the canvas. I stumpled upon this issue searching for options on how to set width and height to a specific value but did not find any. Then I had a look at the source code just to see that JSInterop is overriding my initially set width and height settings. So, I am in the same boat as @Code-Chops requiring the auto size thing to be controllable.

@mattleibow
Copy link
Contributor

mattleibow commented Nov 13, 2024

You should not set width/height of the canvas directly, and instead use the styles:

<SKGLView OnPaintSurface="OnPaintSurface" style="width:100px; height:100px;" />

In order to not have a blurry canvas, we need to change the stile to be <style-size> * <screen-density>:

https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Optimizing_canvas#scaling_for_high_resolution_displays

Is using a style not possible?

@ViRuSTriNiTy
Copy link

@mattleibow Yep, the inline style solution is also discussed in #2038 and specifically comment #2038 (comment) provides a ruleset that avoids the automatic resizing, at least visually, the internal services are still running. I think the issue can be closed.

@mattleibow mattleibow closed this as not planned Won't fix, can't repro, duplicate, stale Nov 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants