-
Notifications
You must be signed in to change notification settings - Fork 77
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
There should be an option to resize the canvas along with the browser window #628
Comments
This is the expected behavior. On the web, resize events are fired only when entering or exiting full-screen mode. |
In that case, what happens if size of the canvas changes (due to CSS) ? Would it just be the same as if you wouldn't handle the resize events on native? |
Could the default size be changed to fill the window? Visiting your game html and having it only take up ~1/4th of the screen (why that size? it must be specified somewhere?) doesn't seem like a good out-of-the-box experience. If I use macroquad for example, everything always resizes to fit in the visible space. I imagine that is closer to the experience most people are looking for, but admittedly I haven't done any kind of poll. |
You can set the size of the canvas through the settings https://github.com/ryanisaacg/quicksilver/blob/master/examples/10_resize.rs#L15 If you ask me how it should work then: |
Possibly my use case is different from other users -- the reason I'm using something like quicksilver is I don't have any web development background (most of my experience is C++ backend), and frameworks like quicksilver seem like a way to make a game that can run on a single webpage by itself, without having to learn all the html/javascript/css details. A lot of the wasm guides seem to assume your goal is to embed some wasm thing in the middle of a regular HTML site and interface with legacy javascript libraries, but I just want to visit mygame.html and have it be the whole document. For people like me it would be nice to not have to think about CSS, but maybe that's unavoidable? |
The canvas changing size due to CSS will not fire an event. I don't believe that listening for a CSS change of the size to fire an event is well-supported by the web platform, but I could be wrong.
Personally I think you're better off having a fixed-size canvas, or going into fullscreen mode. As far as I'm aware, keeping the canvas to the same size as the browser window involves a few hacks.
Yup, that's the default value for |
My solution to this is some rather unfortunate glue code. Essentially just an implementation of this stackoverflow answer. I'm not sure how quicksilver can make this easier, but I am interested in getting rid of this code by implementing something upstream 😛 |
I read the code and the comment. About
as for a way to improve the code by implementing something upstream: I guess having quicksilver expose a function to JS that fires the resize event would improve it? Then people can resize it based on whatever. However, I think that exposing a function like that should be done by winit, rather than quicksilver (winit being the windowing library quicksilver uses) |
@lenscas |
I don't think so, or at the very least that behavior should be configurable. The most flexible and easiest to implement would be to expose a function that sets the new height/width and generates the resize event.
Correct, as stated by @ryanisaacg that is expected behavior.
Either wasm-bindgen or cargo-web generate the files depending on what you use. Not sure wat "this" in that sentence refers to?
|
This follows the changes from here: https://github.com/willmcpherson2/maj/commit/4cb640c818759800a0695657ab5395a5fd398ff7 Further references: - https://stackoverflow.com/questions/4288253/html5-canvas-100-width-height-of-viewport/8486324#8486324 - ryanisaacg/quicksilver#628 (comment) This works nicely on PC. It does not do any zooming, i.e. you will be able to see more at larger resolutions. Not sure if I want to keep it like this. Also, it does not work well on my Phone: the view is quite zoomed in.
This follows the changes from here: https://github.com/willmcpherson2/maj/commit/4cb640c818759800a0695657ab5395a5fd398ff7 Further references: - https://stackoverflow.com/questions/4288253/html5-canvas-100-width-height-of-viewport/8486324#8486324 - ryanisaacg/quicksilver#628 (comment) This works nicely on PC. It does not do any zooming, i.e. you will be able to see more at larger resolutions. Not sure if I want to keep it like this.
This follows the changes from here: https://github.com/willmcpherson2/maj/commit/4cb640c818759800a0695657ab5395a5fd398ff7 Further references: - https://stackoverflow.com/questions/4288253/html5-canvas-100-width-height-of-viewport/8486324#8486324 - ryanisaacg/quicksilver#628 (comment) This works nicely on PC. It does not do any zooming, i.e. you will be able to see more at larger resolutions. Not sure if I want to keep it like this. Also, it does not work well on my Phone: the view is quite zoomed in.
This follows the changes from here: https://github.com/willmcpherson2/maj/commit/4cb640c818759800a0695657ab5395a5fd398ff7 Further references: - https://stackoverflow.com/questions/4288253/html5-canvas-100-width-height-of-viewport/8486324#8486324 - ryanisaacg/quicksilver#628 (comment) This works nicely on PC. It does not do any zooming, i.e. you will be able to see more at larger resolutions. Not sure if I want to keep it like this.
Describe the bug
The demo is always the same size and is always a small part of the screen. Nothing happens when you resize the browser window.
To Reproduce
Copy the resize demo to main.rs, add quicksilver dep, then run
cargo web start --release --auto-reload --features quicksilver/stdweb
and visit in Chrome.Environment and versions (please complete the following information):
The text was updated successfully, but these errors were encountered: