Skip to content

Commit

Permalink
feat: apply several 0.4 features
Browse files Browse the repository at this point in the history
  • Loading branch information
simbleau committed May 20, 2024
1 parent ff6181b commit 7912fa3
Show file tree
Hide file tree
Showing 49 changed files with 873 additions and 452 deletions.
40 changes: 27 additions & 13 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,77 +10,91 @@ Subheadings to categorize changes are `added, changed, deprecated, removed, fixe

## Unreleased

### Changed

- SVG (.svg) support is now added through a cargo feature `svg`.
- Lottie (.json) support is now added through the cargo feature `lottie`.
- experimental `dotLottie` features (`LottiePlayer`, `PlayerTransition`, `PlayerState`) are now feature-gated through the cargo feature `experimental-dotLottie`. This is only partial support, and a work in progress.
- `VelloAsset.metadata()` is no longer available, as it is specific to Lottie. There is now a trait, `LottieExt` that can be imported to call `.metadata()` on a `Composition` instead. This is no longer fallible as a result.
- `PlaybackAlphaOverride` was removed in favor of an `alpha` field on `VelloAsset`.
- `LottiePlayer` was renamed to `DotLottiePlayer`.

### Fixed

- A slow startup delay for lottie assets to begin rendering
- A dotLottie issue where the first frame can jump on web platforms.

## 0.3.3

### fixed
### Fixed

- Projects with a 2D and 3D camera should no longer conflict with `bevy_vello`'s queries.

## 0.3.2

### added
### Added

- Inverse `ZFunction` options added for `BbTop`, `BbBottom`, `BbLeft`, and `BbRight`.

### fixed
### Fixed

- A panic that can happen in the extract schedule of lottie files.
- Z-ordering now works correctly for `Bb` functions.

## 0.3.1 (2024-05-01)

### fixed
### Fixed

- `bevy_vello::prelude::Scene` was removed, since it conflicts with `bevy::prelude::Scene`.

## 0.3.0 (2024-05-01)

### added
### Added

- `VelloAssetAlignment` was added to the `VelloAssetBundle`.

### changed
### Changed

- `VectorFile` enum variants were flattened into tuple structs.

### removed
### Removed

- `bevy_vello::VelloPlugin` was removed from the prelude.

## 0.2.2 (2024-04-22)

### fixed
### Fixed

- Now when a `VelloScene` and `VelloText` have the same Z-Index, text will be rendered above the scene.

## 0.2.1 (2024-04-21)

### fixed
### Fixed

- `VelloTextAlignment` is now in the `bevy_vello::prelude`.
- The playhead now will now always be bounded
- A rare issue where, if an asset was not available, parts of a state would not transition properly.

## 0.2.0 (2024-04-17)

### added
### Added

- Added the `VelloTextAlignment` component to `VelloTextBundle`, which now helps control the alignment of text.
- Added the `VelloTextAlignment` to the `bevy_vello::prelude`.

### fixed
### Fixed

- Text bounding boxes are now tighter as they are capped by the baseline.

## 0.1.2 (2024-04-08)

### fixed
### Fixed

- Fixes a window hang issue in bevy on native platforms

## 0.1.1 (2024-04-04)

### fixed
### Fixed

- fixed panic on Windows when window is minimized

Expand Down
12 changes: 11 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ members = [

[workspace.package]
edition = "2021"
version = "0.3.3"
version = "0.4.0"
license = "MIT OR Apache-2.0"
repository = "https://github.com/loopystudios/bevy_vello"

Expand Down Expand Up @@ -52,5 +52,15 @@ vello_svg = "0.1.0"
velato = "0.1.0"
once_cell = "1.19.0"

# TODO: Remove after https://github.com/linebender/velato/pull/19
serde_json = { optional = true, version = "1" }

[dev-dependencies]
wasm-bindgen-test = "0.3.42"

[features]
default = ["svg", "lottie"]
svg = []
# TODO: Remove `serde_json` after https://github.com/linebender/velato/pull/19
lottie = ["serde_json"]
experimental-dotLottie = ["lottie"]
39 changes: 13 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,18 @@

**A vector graphics rendering integration for [Bevy game engine](https://bevyengine.org) using [Vello](https://vello.dev).**

[![Discord](https://img.shields.io/discord/913957940560531456.svg?label=Loopy&logo=discord&logoColor=ffffff&color=ffffff&labelColor=000000)](https://discord.gg/zrjnQzdjCB)
[![Linebender Zulip](https://img.shields.io/badge/Linebender-%23gpu-blue?logo=Zulip)](https://xi.zulipchat.com/#narrow/stream/197075-gpu)
[![MIT/Apache 2.0](https://img.shields.io/badge/license-MIT%2FApache-blue.svg)](#license)
[![Vello](https://img.shields.io/badge/vello-v0.1.0-purple.svg)](https://crates.io/crates/vello)
[![Following released Bevy versions](https://img.shields.io/badge/bevy%20tracking-released%20version-lightblue)](https://bevyengine.org/learn/quick-start/plugin-development/#main-branch-tracking)

[![Following released Bevy versions](https://img.shields.io/badge/bevy%20tracking-released%20version-lightblue)](https://bevyengine.org/learn/quick-start/plugin-development/#main-branch-tracking)\
[![Dependency status](https://deps.rs/repo/github/loopystudios/bevy_vello/status.svg)](https://deps.rs/repo/github/loopystudios/bevy_vello)
[![Crates.io](https://img.shields.io/crates/v/bevy_vello.svg)](https://crates.io/crates/bevy_vello)
[![Docs](https://img.shields.io/docsrs/bevy_vello)](https://docs.rs/bevy_vello)
[![Build status](https://github.com/loopystudios/bevy_vello/workflows/CI/badge.svg)](https://github.com/loopystudios/bevy_vello/actions)

</div>

> [!WARNING]
> The support of SVG and Lottie is limited. If there is an SVG-related issue, please file the issue in [`vello_svg`](https://github.com/linebender/vello_svg). If there is a Lottie-related issue, please file the issue in [`velato`](https://github.com/linebender/velato). Please see the respective backends for for more information about limitations.
bevy_vello is a rendering integration for rendering vector graphics in the Bevy game engine. Currently it renders standard vello `Scene`s, as well as SVG and Lottie files.
`bevy_vello` is a cross-platform, 2D compute-centric vector graphics rendering library for Bevy. There is default support for rendering text and scenes, with additional opt-in features for SVG and Lottie. Experimental support for dotLottie is coming.

Quickstart to run the demo:

Expand All @@ -29,32 +25,23 @@ cargo run -p demo

![Alt text](image.png)

It uses several support backends for assets:

- [`vello_svg`](https://github.com/linebender/vello_svg) - Converting SVG files to a vello `Scene`
- [`velato`](https://github.com/linebender/velato) - Converting Lottie files to a vello `Scene`

Visual inconsistencies discovered should be reported to the respective backend.

## Bevy version support

**NOTE**: You must use a git rev for now, but we are planning a publish. See [issue #3](https://github.com/loopystudios/bevy_vello/issues/3).

|bevy|bevy_vello|
|---|---|
|0.13|0.1-0.3, main|
|< 0.13| unsupported |

## Features
## Cargo features

> [!WARNING]
> The support of SVG and Lottie is limited. If there is an SVG-related issue, please file the issue in [`vello_svg`](https://github.com/linebender/vello_svg). If there is a Lottie-related issue, please file the issue in [`velato`](https://github.com/linebender/velato). Please see the respective backends for for more information about limitations.
- Spawn vector graphics rendering in screen-space or world-space coordinates.
- Runtime color swapping of Lottie files with a `Theme` component.
- Augment playback options with a `PlaybackOptions` component.
- Limited state machine support with a `LottiePlayer` component.
- Text
- NOTE: To avoid conflict with bevy's built-in font loader, rename fonts used by `bevy_vello` to end with `*.vtff`. This is a limitation of the bevy game engine, and can probably be an improvement in the future.
- Debug drawing for bounding boxes and origin
- Render immediate-mode vello `Scene`s
|Cargo feature|Description|Default?|
|---|---|----|
|`svg`|Render `.svg` files with [`vello_svg`](https://github.com/linebender/vello_svg)|Yes|
|`lottie`|Render `.json` Lottie files with [`velato`](https://github.com/linebender/velato)|Yes|
|`experimental-dotLottie`|Render `.lottie` Lottie files. **Work in Progress**|No|

## Examples

Expand Down Expand Up @@ -86,7 +73,7 @@ There is also a web demo [available here](https://loopystudios.github.io/bevy_ve
## Community

All Loopy projects and development happens in the [Loopy Discord](https://discord.gg/zrjnQzdjCB). The discord is open to the public.
Discussion of Vello development happens in the [Linebender Zulip](https://xi.zulipchat.com/), specifically the [#gpu stream](https://xi.zulipchat.com/#narrow/stream/197075-gpu). All public content can be read without logging in.

Contributions are welcome by pull request. The [Rust code of conduct](https://www.rust-lang.org/policies/code-of-conduct) applies.

Expand Down
2 changes: 1 addition & 1 deletion examples/demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ publish = false

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
bevy_vello = { path = "../../" }
bevy_vello = { path = "../../", features = ["experimental-dotLottie"] }
bevy = { workspace = true }
bevy_pancam = { version = "0.11", features = ["bevy_egui"] }
bevy_egui = "0.25"
Expand Down
6 changes: 3 additions & 3 deletions examples/demo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn setup_vector_graphics(mut commands: Commands, asset_server: ResMut<AssetServe
..default()
})
.insert(
LottiePlayer::new("stopped")
DotLottiePlayer::new("stopped")
.with_state({
PlayerState::new("stopped")
.playback_options(PlaybackOptions {
Expand Down Expand Up @@ -74,10 +74,10 @@ fn print_metadata(
for ev in asset_ev.read() {
if let AssetEvent::LoadedWithDependencies { id } = ev {
let asset = assets.get(*id).unwrap();
if let Some(metadata) = asset.metadata() {
if let VectorFile::Lottie(composition) = &asset.file {
info!(
"Animated asset loaded. Layers:\n{:#?}",
metadata.get_layers().collect::<Vec<_>>()
composition.as_ref().get_layers().collect::<Vec<_>>()
);
}
}
Expand Down
7 changes: 3 additions & 4 deletions examples/demo/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::time::Duration;
pub fn controls_ui(
mut contexts: EguiContexts,
mut player: Query<(
&mut LottiePlayer,
&mut DotLottiePlayer,
&mut Playhead,
&mut PlaybackOptions,
&mut Theme,
Expand All @@ -22,8 +22,7 @@ pub fn controls_ui(
};

let asset = assets.get(handle.id()).unwrap();
let metadata = asset.metadata().unwrap();
let VectorFile::Lottie(composition) = &asset.data else {
let VectorFile::Lottie(composition) = &asset.file else {
return;
};

Expand Down Expand Up @@ -243,7 +242,7 @@ pub fn controls_ui(
});

ui.heading("Theme");
for layer in metadata.get_layers() {
for layer in composition.as_ref().get_layers() {
let color = theme.get_mut(layer).cloned().unwrap_or_default();
let mut color_edit = [color.r(), color.g(), color.b(), color.a()];
ui.horizontal(|ui| {
Expand Down
91 changes: 91 additions & 0 deletions examples/z_ordering/src/assets/fonts/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL


-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 7912fa3

Please sign in to comment.