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

Implement saving map as image file #131

Merged
merged 8 commits into from
Jun 15, 2024
Merged

Conversation

white-axe
Copy link
Collaborator

Description
This pull request adds a "Save map preview" button to the map editor that saves the current state of the map, with all currently visible layers, as a PNG file.

The implementation is in the save_as_image function in crates/components/src/map_view.rs.

Testing
On an arbitrary map, the button should be able to correctly render all visible map layers and events, with layer darkening if it's enabled. Also it should be able to render the grid and collision layers if they're enabled. It should also be able to render maps that are larger than the maximum texture dimensions allowed by wgpu (it does this by breaking the map into large tiles and rendering them individually before combining them together).

Checklist

  • Run cargo fmt.
  • Run cargo clippy. If applicable, add:
    • --target wasm32-unknown-unknown -Z build-std=std,panic_abort
  • Run cargo build --release
  • If applicable, run trunk build --release

This fixes a bug where when the size of the map editor changes, the grid
shader's internally stored value for the size of the map editor's
viewport doesn't get updated until one frame later if the shader is
using push constants. This caused the thicknesses of the grid lines to
be inaccurate for a frame after resizing.
@white-axe white-axe added the enhancement New feature or request label Jun 13, 2024
@white-axe white-axe requested a review from a team as a code owner June 13, 2024 18:28
@Speak2Erase Speak2Erase merged commit 8cdf1a9 into Astrabit-ST:dev Jun 15, 2024
5 checks passed
@white-axe white-axe deleted the screenshot branch June 15, 2024 17:01
MolassesLover pushed a commit to MolassesLover/luminol-molasses that referenced this pull request Jul 23, 2024
* fix: fix 1 frame delay when grid shader viewport size changes

This fixes a bug where when the size of the map editor changes, the grid
shader's internally stored value for the size of the map editor's
viewport doesn't get updated until one frame later if the shader is
using push constants. This caused the thicknesses of the grid lines to
be inaccurate for a frame after resizing.

* feat: add "Save map preview" button for saving map as image

* style: replace `ScreenshotState` with an async block

* perf: don't use padding in the texture when screenshotting

* feat: handle screenshotting for maps larger than max texture size

* fix: fix `width_padded` alignment value

* style: remove unnecessary rounding from `max_texture_width`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants