bevyengine / bevyengine/bevy

Support load .svg images

Open
#1,139 17 comments 30 reactions 0 assignees View on GitHub
A-Assets C-Feature D-Complex S-Needs-Design-Doc
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

**What problem does this solve or what need does it fill?**

Allow bevy to load svg vector images

**Describe the solution would you like?**

Using [resvg](https://github.com/RazrFalcon/resvg) crate, bevy can easily support svg images

**Describe the alternative(s) you've considered?**

None

**Additional context**

I added a `SvgTextureLoader` and then rendered the image using resvg and now it works fine.

```rust
let texture_handle = asset_server.load("branding/bevy_logo_light.svg");
```

Screen Shot

One troublesome question, since svg is vector, how do we determine the size of the image?

Before rendering the svg we have to determine the size

```rust
pub enum FitTo {
/// Keep original size.
Original,
/// Scale to width.
Width(u32),
/// Scale to height.
Height(u32),
/// Zoom by factor.
Zoom(f32),
}
```

Maybe we can?

```rust
// Default
asset_server.load("branding/bevy_logo_light.svg");
// Scale
asset_server.load("branding/bevy_logo_light.svg?10.0");
asset_server.load("branding/bevy_logo_light.svg#width=1000.");
```

Bad scenario:
Re-render at each zoom?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.