Implement saving map as image file #131
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
cargo fmt
.cargo clippy
. If applicable, add:--target wasm32-unknown-unknown -Z build-std=std,panic_abort
cargo build --release
trunk build --release