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

v0.5.0 - Update to bevy 0.14 #61

Merged
merged 16 commits into from
Jul 6, 2024
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
run: cargo clippy -- -D warnings

- name: Build | Rustfmt
run: cargo fmt --all -- --check
run: cargo fmt -- --check
simbleau marked this conversation as resolved.
Show resolved Hide resolved

check:
runs-on: ubuntu-latest
Expand All @@ -43,7 +43,7 @@ jobs:
uses: Swatinem/rust-cache@v2

- name: Build | Check (native)
run: cargo check --all
run: cargo check

- name: Build | Check (wasm)
run: cargo check --target wasm32-unknown-unknown
Expand All @@ -70,7 +70,7 @@ jobs:
uses: Swatinem/[email protected]

- name: Build | Test (native)
run: cargo test --all
run: cargo test

- name: Build | Test (wasm)
run: wasm-pack test --node
18 changes: 17 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,30 @@ Subheadings to categorize changes are `added, changed, deprecated, removed, fixe

## Unreleased

## 0.5.0

### Added

- New `scene-ui` example demonstrating a `VelloScene` attached to a `bevy::ui::Node`
- New `scene_ui` example demonstrating a `VelloScene` attached to a `bevy::ui::Node`
simbleau marked this conversation as resolved.
Show resolved Hide resolved

### Changed

- Updated to bevy 0.14
- Updated to vello 0.2
- Updated to velato 0.3
- Updated to vello_svg 0.3

### Fixed

- Removed `Arc` in another `Arc` for `VelloFont`
- Opacity now correctly applies to SVG assets.
- Opacity now applies correctly to the lottie image group, rather than each element and path within it, causing overdraw.
- `VelloScene` components on `bevy::ui::Node` entities now account for Bevy's UI layout systems and render at the expected viewport coordinates

### Removed

- Pancam and/or egui from all examples besides the demo, as external dependencies can bottleneck upgrading to the next bevy version.

## 0.4.2

### Fixed
Expand Down
15 changes: 8 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@ members = [
"examples/scene",
"examples/svg",
"examples/lottie",
"examples/scene-ui",
"examples/scene_ui",
]

[workspace.package]
edition = "2021"
version = "0.4.2"
version = "0.5.0"
license = "MIT OR Apache-2.0"
repository = "https://github.com/linebender/bevy_vello"

[workspace.dependencies]
bevy = { version = "0.13.0", default-features = false, features = [
bevy = { version = "0.14.0", default-features = false, features = [
"bevy_asset",
"bevy_winit",
"bevy_core_pipeline",
"bevy_pbr",
"bevy_render",
"bevy_ui",
"multi-threaded",
"multi_threaded",
"x11",
"tonemapping_luts",
"bevy_gizmos",
Expand All @@ -50,9 +50,10 @@ repository.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
bevy = { workspace = true }
vello = "0.1.0"
vello_svg = "0.2.0"
velato = "0.2.0"
vello = "0.2.0"
vello_svg = "0.3.0"
velato = "0.3.0"
thiserror = "1.0.61"
once_cell = "1.19.0"

[dev-dependencies]
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

[![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)
[![Vello](https://img.shields.io/badge/vello-v0.2.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)\
[![Dependency status](https://deps.rs/repo/github/linebender/bevy_vello/status.svg)](https://deps.rs/repo/github/linebender/bevy_vello)
[![Crates.io](https://img.shields.io/crates/v/bevy_vello.svg)](https://crates.io/crates/bevy_vello)
Expand All @@ -29,7 +29,8 @@ cargo run -p demo

|bevy|bevy_vello|
|---|---|
|0.13|0.1-0.4, main|
|0.14|0.5, main|
|0.13|0.1-0.4|
|< 0.13| unsupported |

## Cargo features
Expand Down
3 changes: 1 addition & 2 deletions examples/demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ publish = false
bevy_vello = { path = "../../", features = ["experimental-dotLottie"] }
bevy = { workspace = true }
bevy_pancam = { version = "0.11", features = ["bevy_egui"] }
bevy_egui = "0.25"
console_error_panic_hook = "0.1"
bevy_egui = "0.28.0"
39 changes: 22 additions & 17 deletions examples/demo/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
mod ui;

use bevy::asset::io::embedded::EmbeddedAssetRegistry;
use bevy::asset::{embedded_asset, AssetMetaCheck};
use bevy::prelude::*;
use bevy::{
asset::{embedded_asset, io::embedded::EmbeddedAssetRegistry, AssetMetaCheck},
color::palettes::css,
prelude::*,
};
use bevy_egui::EguiPlugin;
use bevy_vello::{prelude::*, VelloPlugin};

fn main() {
let mut app = App::new();
app.insert_resource(AssetMetaCheck::Never)
.add_plugins(DefaultPlugins)
.add_plugins(EguiPlugin)
.add_plugins(VelloPlugin)
.init_resource::<EmbeddedAssetRegistry>()
.add_plugins(bevy_pancam::PanCamPlugin)
.add_systems(Startup, setup_vector_graphics)
.add_systems(Update, (print_metadata, ui::controls_ui));
app.add_plugins(DefaultPlugins.set(AssetPlugin {
meta_check: AssetMetaCheck::Never,
..default()
}))
.add_plugins(EguiPlugin)
.add_plugins(VelloPlugin)
.init_resource::<EmbeddedAssetRegistry>()
//.add_plugins(bevy_pancam::PanCamPlugin)
.add_systems(Startup, setup_vector_graphics)
.add_systems(Update, (print_metadata, ui::controls_ui));
embedded_asset!(app, "assets/calendar.json");
app.run();
}

fn setup_vector_graphics(mut commands: Commands, asset_server: ResMut<AssetServer>) {
commands.spawn((Camera2dBundle::default(), bevy_pancam::PanCam::default()));
commands.spawn(Camera2dBundle::default());
//commands.spawn((Camera2dBundle::default(), bevy_pancam::PanCam::default()));
commands
.spawn(VelloAssetBundle {
vector: asset_server.load::<VelloAsset>("embedded://demo/assets/calendar.json"),
Expand All @@ -38,29 +43,29 @@ fn setup_vector_graphics(mut commands: Commands, asset_server: ResMut<AssetServe
autoplay: false,
..default()
})
.theme(Theme::new().add("calendar", Color::BLUE))
.theme(Theme::new().add("calendar", css::YELLOW.into()))
.transition(PlayerTransition::OnMouseEnter { state: "play" })
.reset_playhead_on_start()
})
.with_state(
PlayerState::new("play")
.playback_options(PlaybackOptions {
looping: PlaybackLoopBehavior::DoNotLoop,
speed: 0.25,
speed: 0.75,
..default()
})
.theme(Theme::new().add("calendar", Color::GREEN))
.theme(Theme::new().add("calendar", css::LIME.into()))
.transition(PlayerTransition::OnMouseLeave { state: "rev" }),
)
.with_state(
PlayerState::new("rev")
.playback_options(PlaybackOptions {
looping: PlaybackLoopBehavior::DoNotLoop,
direction: PlaybackDirection::Reverse,
speed: 0.25,
speed: 0.75,
..default()
})
.theme(Theme::new().add("calendar", Color::RED))
.theme(Theme::new().add("calendar", css::RED.into()))
.transition(PlayerTransition::OnMouseEnter { state: "play" })
.transition(PlayerTransition::OnComplete { state: "stopped" }),
),
Expand Down
32 changes: 20 additions & 12 deletions examples/demo/src/ui.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use bevy::prelude::*;
use bevy_egui::egui::{self};
use bevy_egui::EguiContexts;
use bevy_vello::prelude::*;
use bevy_vello::vello_svg::usvg::strict_num::Ulps;
use bevy_egui::{
egui::{self, Color32},
EguiContexts,
};
use bevy_vello::{prelude::*, vello_svg::usvg::strict_num::Ulps};
use std::time::Duration;

pub fn controls_ui(
Expand Down Expand Up @@ -47,6 +48,11 @@ pub fn controls_ui(
player.pause();
playhead.seek(frame);
};
if player.is_stopped() {
ui.colored_label(Color32::RED, "stopped");
} else if !player.is_playing() {
ui.colored_label(Color32::YELLOW, "paused");
}
});

ui.horizontal_wrapped(|ui| {
Expand Down Expand Up @@ -244,20 +250,22 @@ pub fn controls_ui(
ui.heading("Theme");
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()];
let color = color.to_srgba().to_u8_array();
let mut color32 =
Color32::from_rgba_unmultiplied(color[0], color[1], color[2], color[3]);
ui.horizontal(|ui| {
if ui
.color_edit_button_rgba_unmultiplied(&mut color_edit)
.changed()
{
let [r, g, b, a] = color_edit;
if ui.color_edit_button_srgba(&mut color32).changed() {
let r = color32.r();
let g = color32.g();
let b = color32.b();
let a = color32.a();
player
.state_mut()
.theme
.as_mut()
.unwrap()
.edit(layer, Color::rgba(r, g, b, a));
theme.edit(layer, Color::rgba(r, g, b, a));
.edit(layer, Color::srgba_u8(r, g, b, a));
theme.edit(layer, Color::srgba_u8(r, g, b, a));
};
ui.label(layer);
});
Expand Down
18 changes: 11 additions & 7 deletions examples/drag_n_drop/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
use bevy::asset::{embedded_asset, AssetMetaCheck};
use bevy::prelude::*;
use bevy::{
asset::{embedded_asset, AssetMetaCheck},
prelude::*,
};
use bevy_vello::{prelude::*, VelloPlugin};

fn main() {
let mut app = App::new();
app.insert_resource(AssetMetaCheck::Never)
.add_plugins(DefaultPlugins)
.add_plugins(VelloPlugin)
.add_systems(Startup, setup_vector_graphics)
.add_systems(Update, drag_and_drop);
app.add_plugins(DefaultPlugins.set(AssetPlugin {
meta_check: AssetMetaCheck::Never,
..default()
}))
.add_plugins(VelloPlugin)
.add_systems(Startup, setup_vector_graphics)
.add_systems(Update, drag_and_drop);
embedded_asset!(app, "assets/fountain.svg");
app.run();
}
Expand Down
16 changes: 10 additions & 6 deletions examples/lottie/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
use bevy::asset::{embedded_asset, AssetMetaCheck};
use bevy::prelude::*;
use bevy::{
asset::{embedded_asset, AssetMetaCheck},
prelude::*,
};
use bevy_vello::{prelude::*, VelloPlugin};

fn main() {
let mut app = App::new();
app.insert_resource(AssetMetaCheck::Never)
.add_plugins(DefaultPlugins)
.add_plugins(VelloPlugin)
.add_systems(Startup, load_lottie);
app.add_plugins(DefaultPlugins.set(AssetPlugin {
meta_check: AssetMetaCheck::Never,
..default()
}))
.add_plugins(VelloPlugin)
.add_systems(Startup, load_lottie);
embedded_asset!(app, "assets/Tiger.json");
app.run();
}
Expand Down
12 changes: 6 additions & 6 deletions examples/scene/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
use bevy::asset::AssetMetaCheck;
use bevy::prelude::*;
use bevy_vello::vello::{kurbo, peniko};
use bevy_vello::{prelude::*, VelloPlugin};
use bevy_vello::{
prelude::*,
vello::{kurbo, peniko},
VelloPlugin,
};

fn main() {
App::new()
.insert_resource(AssetMetaCheck::Never)
.add_plugins(DefaultPlugins)
.add_plugins(VelloPlugin)
.add_systems(Startup, setup_vector_graphics)
.add_systems(Update, simple_animation)
.run()
.run();
}

fn setup_vector_graphics(mut commands: Commands) {
Expand All @@ -21,7 +22,6 @@ fn setup_vector_graphics(mut commands: Commands) {
fn simple_animation(mut query_scene: Query<(&mut Transform, &mut VelloScene)>, time: Res<Time>) {
let sin_time = time.elapsed_seconds().sin().mul_add(0.5, 0.5);
let (mut transform, mut scene) = query_scene.single_mut();

// Reset scene every frame
*scene = VelloScene::default();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "scene-ui"
name = "scene_ui"
version.workspace = true
license.workspace = true
edition.workspace = true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::f64::consts::{FRAC_PI_4, SQRT_2};

use bevy::prelude::*;
use bevy::{color::palettes::css, prelude::*};
use bevy_vello::{prelude::*, VelloPlugin};
use std::f64::consts::{FRAC_PI_4, SQRT_2};

fn main() {
App::new()
Expand All @@ -27,7 +26,7 @@ fn setup_ui(mut commands: Commands) {
border: UiRect::all(Val::Px(2.0)),
..default()
},
border_color: Color::FUCHSIA.with_a(0.5).into(),
border_color: css::FUCHSIA.with_alpha(0.5).into(),
..default()
},
Interaction::default(),
Expand Down
16 changes: 10 additions & 6 deletions examples/svg/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
use bevy::asset::{embedded_asset, AssetMetaCheck};
use bevy::prelude::*;
use bevy::{
asset::{embedded_asset, AssetMetaCheck},
prelude::*,
};
use bevy_vello::{prelude::*, VelloPlugin};

fn main() {
let mut app = App::new();
app.insert_resource(AssetMetaCheck::Never)
.add_plugins(DefaultPlugins)
.add_plugins(VelloPlugin)
.add_systems(Startup, load_svg);
app.add_plugins(DefaultPlugins.set(AssetPlugin {
meta_check: AssetMetaCheck::Never,
..default()
}))
.add_plugins(VelloPlugin)
.add_systems(Startup, load_svg);
embedded_asset!(app, "assets/fountain.svg");
app.run();
}
Expand Down
Loading
Loading