Skip to content

Commit

Permalink
BREAKING: update to bevy 0.14
Browse files Browse the repository at this point in the history
  • Loading branch information
nixon-voxell committed Aug 3, 2024
1 parent 3f0ed62 commit bbd6a49
Show file tree
Hide file tree
Showing 17 changed files with 936 additions and 693 deletions.
1,513 changes: 875 additions & 638 deletions Cargo.lock

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ edition = "2021"
license = "MIT OR Apache-2.0"
repository = "https://github.com/nixon-voxell/bevy_motiongfx"

[workspace.dependencies]
bevy = { version = "0.14", default-features = false }
bevy_vello_graphics = { version = "0.1.0", git = "https://github.com/voxell-tech/bevy_vello_graphics" }
smallvec = "1"

[package]
name = "bevy_motiongfx"
categories = ["graphics", "gui", "rendering", "motion-graphics", "vector-graphics"]
Expand All @@ -21,7 +26,7 @@ license.workspace = true
repository.workspace = true

[dependencies]
bevy = { version = "0.13", default-features = false }
bevy = { workspace = true }
motiongfx_core = { version = "0.1.0", path = "crates/motiongfx_core" }
motiongfx_common = { version = "0.1.0", path = "crates/motiongfx_common", optional = true }
motiongfx_vello = { version = "0.1.0", path = "crates/motiongfx_vello", optional = true }
Expand All @@ -32,7 +37,7 @@ common = ["dep:motiongfx_common"]
vello_graphics = ["dep:motiongfx_vello"]

[dev-dependencies]
bevy = "0.13"
bevy = "0.14"

[workspace.lints.clippy]
redundant_type_annotations = "warn"
Expand Down
2 changes: 1 addition & 1 deletion crates/motiongfx_common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ license.workspace = true
repository.workspace = true

[dependencies]
bevy = { version = "0.13", default-features = false }
bevy = { workspace = true }
motiongfx_core = { version = "0.1.0", path = "../motiongfx_core" }

[lints]
Expand Down
3 changes: 2 additions & 1 deletion crates/motiongfx_common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use bevy::{
ecs::system::{EntityCommand, EntityCommands},
prelude::*,
};
use motiongfx_core::prelude::*;
use motiongfx_core::{prelude::*, UpdateSequenceSet};

pub mod motion;

Expand All @@ -28,6 +28,7 @@ impl Plugin for MotionGfxCommonPlugin {
update_component::<Sprite, Color>,
update_component::<Sprite, f32>,
update_asset::<StandardMaterial, Color>,
update_asset::<StandardMaterial, LinearRgba>,
update_asset::<StandardMaterial, f32>,
update_asset::<ColorMaterial, Color>,
update_asset::<ColorMaterial, f32>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl<'a> StandardMaterialMotionBuilder<'a> {
Self { id, material }
}

pub fn to_emissive(&mut self, color: Color) -> Action<Color, StandardMaterial> {
pub fn to_emissive(&mut self, color: LinearRgba) -> Action<LinearRgba, StandardMaterial> {
act!(
(self.id, StandardMaterial),
start = { self.material }.emissive,
Expand Down
8 changes: 4 additions & 4 deletions crates/motiongfx_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ license.workspace = true
repository.workspace = true

[dependencies]
bevy = { version = "0.13", default-features = false }
bevy_vello = { version = "0.4", optional = true }
bevy_vello_graphics = { version = "0.1.0", git = "https://github.com/voxell-tech/bevy_vello_graphics", optional = true }
bevy = { workspace = true }
bevy_vello_graphics = { workspace = true, optional = true }
smallvec = { workspace = true }
motiongfx_core_macros = { version = "0.1.0", path = "macros" }

[lints]
workspace = true

[features]
default = []
vello_graphics = ["dep:bevy_vello_graphics", "dep:bevy_vello"]
vello_graphics = ["dep:bevy_vello_graphics"]
30 changes: 15 additions & 15 deletions crates/motiongfx_core/src/color_palette.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,22 @@ impl Default for ColorPalette<ColorKey> {
Self::new(
[
// Primary colors
(ColorKey::Red, Color::hex("FF6188").unwrap()),
(ColorKey::Orange, Color::hex("FC9867").unwrap()),
(ColorKey::Yellow, Color::hex("FFD866").unwrap()),
(ColorKey::Green, Color::hex("A9DC76").unwrap()),
(ColorKey::Blue, Color::hex("78DCE8").unwrap()),
(ColorKey::Purple, Color::hex("AB9DF2").unwrap()),
(ColorKey::Red, Srgba::hex("FF6188").unwrap().into()),
(ColorKey::Orange, Srgba::hex("FC9867").unwrap().into()),
(ColorKey::Yellow, Srgba::hex("FFD866").unwrap().into()),
(ColorKey::Green, Srgba::hex("A9DC76").unwrap().into()),
(ColorKey::Blue, Srgba::hex("78DCE8").unwrap().into()),
(ColorKey::Purple, Srgba::hex("AB9DF2").unwrap().into()),
// Base colors, sorted from darkest to lightest
(ColorKey::Base0, Color::hex("19181A").unwrap()),
(ColorKey::Base1, Color::hex("221F22").unwrap()),
(ColorKey::Base2, Color::hex("2D2A2E").unwrap()),
(ColorKey::Base3, Color::hex("403E41").unwrap()),
(ColorKey::Base4, Color::hex("5B595C").unwrap()),
(ColorKey::Base5, Color::hex("727072").unwrap()),
(ColorKey::Base6, Color::hex("939293").unwrap()),
(ColorKey::Base7, Color::hex("C1C0C0").unwrap()),
(ColorKey::Base8, Color::hex("FCFCFA").unwrap()),
(ColorKey::Base0, Srgba::hex("19181A").unwrap().into()),
(ColorKey::Base1, Srgba::hex("221F22").unwrap().into()),
(ColorKey::Base2, Srgba::hex("2D2A2E").unwrap().into()),
(ColorKey::Base3, Srgba::hex("403E41").unwrap().into()),
(ColorKey::Base4, Srgba::hex("5B595C").unwrap().into()),
(ColorKey::Base5, Srgba::hex("727072").unwrap().into()),
(ColorKey::Base6, Srgba::hex("939293").unwrap().into()),
(ColorKey::Base7, Srgba::hex("C1C0C0").unwrap().into()),
(ColorKey::Base8, Srgba::hex("FCFCFA").unwrap().into()),
]
.into(),
)
Expand Down
13 changes: 7 additions & 6 deletions crates/motiongfx_core/src/f32lerp/bevy_f32lerp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ use super::F32Lerp;

impl F32Lerp for Color {
fn f32lerp(&self, rhs: &Self, t: f32) -> Self {
Self::rgba(
f32::lerp(self.r(), rhs.r(), t),
f32::lerp(self.g(), rhs.g(), t),
f32::lerp(self.b(), rhs.b(), t),
f32::lerp(self.a(), rhs.a(), t),
)
Color::mix(self, rhs, t)
}
}

impl F32Lerp for LinearRgba {
fn f32lerp(&self, rhs: &Self, t: f32) -> Self {
LinearRgba::mix(self, rhs, t)
}
}

Expand Down
4 changes: 2 additions & 2 deletions crates/motiongfx_core/src/f32lerp/vello_f32lerp.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use bevy::{prelude::*, utils::smallvec};
use bevy_vello::prelude::*;
use bevy::prelude::*;
use bevy_vello_graphics::prelude::*;

use super::F32Lerp;

Expand Down
1 change: 0 additions & 1 deletion crates/motiongfx_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ pub mod prelude {
},
slide::{create_slide, SlideBundle, SlideController, SlideCurrState, SlideTargetState},
tuple_motion::{GetId, GetMut, GetMutValue},
MotionGfxPlugin, UpdateSequenceSet,
};
}

Expand Down
4 changes: 2 additions & 2 deletions crates/motiongfx_vello/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ license.workspace = true
repository.workspace = true

[dependencies]
bevy = { version = "0.13", default-features = false }
bevy_vello_graphics = { version = "0.1.0", git = "https://github.com/voxell-tech/bevy_vello_graphics" }
bevy = { workspace = true }
bevy_vello_graphics = { workspace = true }
motiongfx_core = { version = "0.1.0", path = "../motiongfx_core", features = ["vello_graphics"] }

[lints]
Expand Down
5 changes: 1 addition & 4 deletions crates/motiongfx_vello/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ pub mod motion;
// pub mod svg;

pub mod prelude {
pub use crate::{
motion::{fill_motion::FillMotion, stroke_motion::StrokeMotion},
MotionGfxVelloPlugin,
};
pub use crate::motion::{fill_motion::FillMotion, stroke_motion::StrokeMotion};

pub use bevy_vello_graphics::prelude::*;
}
Expand Down
9 changes: 5 additions & 4 deletions crates/motiongfx_vello/src/motion/fill_motion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ impl<'a> FillMotionBuilder<'a> {
}

pub fn to_color(&mut self, color: Color) -> Action<peniko::Brush, Fill> {
let linear = color.to_linear();
act!(
(self.id, Fill),
start = { self.fill }.brush.value,
end = peniko::Brush::Solid(peniko::Color::rgba(
color.r() as f64,
color.g() as f64,
color.b() as f64,
color.a() as f64
linear.red as f64,
linear.green as f64,
linear.blue as f64,
linear.alpha as f64
)),
)
}
Expand Down
8 changes: 4 additions & 4 deletions examples/easings.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use bevy::{core_pipeline::bloom::BloomSettings, pbr::NotShadowCaster, prelude::*};
use bevy_motiongfx::prelude::*;
use bevy_motiongfx::{prelude::*, BevyMotionGfxPlugin};

fn main() {
App::new()
// Bevy plugins
.add_plugins(DefaultPlugins)
// Custom plugins
.add_plugins(MotionGfxPlugin)
.add_plugins(BevyMotionGfxPlugin)
.add_systems(Startup, (setup, easings))
.add_systems(Update, timeline_movement)
.run();
Expand Down Expand Up @@ -36,7 +36,7 @@ fn easings(mut commands: Commands, mut meshes: ResMut<Assets<Mesh>>) {
let mesh_handle = meshes.add(Sphere::default());
let material = StandardMaterial {
base_color: Color::WHITE,
emissive: palette.get(ColorKey::Blue) * 100.0,
emissive: palette.get(ColorKey::Blue).to_linear() * 100.0,
..default()
};

Expand Down Expand Up @@ -75,7 +75,7 @@ fn easings(mut commands: Commands, mut meshes: ResMut<Assets<Mesh>>) {
})
.add_motion(
s.std_material()
.to_emissive(palette.get(ColorKey::Red) * 100.0)
.to_emissive(palette.get(ColorKey::Red).to_linear() * 100.0)
.animate(1.0),
)
.all()
Expand Down
6 changes: 4 additions & 2 deletions examples/hello_world.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use bevy::{core_pipeline::tonemapping::Tonemapping, pbr::NotShadowCaster, prelude::*};
use bevy_motiongfx::prelude::*;
use bevy_motiongfx::{prelude::*, BevyMotionGfxPlugin};

fn main() {
App::new()
// Bevy plugins
.add_plugins(DefaultPlugins)
// Custom plugins
.add_plugins(MotionGfxPlugin)
.add_plugins(BevyMotionGfxPlugin)
.add_systems(Startup, (setup, hello_world))
.add_systems(Update, timeline_movement)
.run();
Expand Down Expand Up @@ -130,6 +130,8 @@ fn timeline_movement(
time: Res<Time>,
) {
for (mut sequence_player, mut sequence_time) in q_timelines.iter_mut() {
println!("timeline movement");
println!("target_time: {}", sequence_time.target_time);
if keys.pressed(KeyCode::KeyD) {
sequence_time.target_time += time.delta_seconds();
}
Expand Down
4 changes: 2 additions & 2 deletions examples/slide_basic.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use bevy::{core_pipeline::bloom::BloomSettings, pbr::NotShadowCaster, prelude::*};
use bevy_motiongfx::prelude::*;
use bevy_motiongfx::{prelude::*, BevyMotionGfxPlugin};

fn main() {
App::new()
// Bevy plugins
.add_plugins(DefaultPlugins)
// Custom plugins
.add_plugins(MotionGfxPlugin)
.add_plugins(BevyMotionGfxPlugin)
.add_systems(Startup, (setup, slide_basic))
.add_systems(Update, slide_movement)
.run();
Expand Down
8 changes: 4 additions & 4 deletions examples/vello_basic.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use bevy::{math::DVec2, prelude::*};
use bevy_motiongfx::prelude::*;
use bevy_motiongfx::{prelude::*, BevyMotionGfxPlugin};

fn main() {
App::new()
// Bevy plugins
.add_plugins(DefaultPlugins)
// Custom plugins
.add_plugins((MotionGfxPlugin, MotionGfxVelloPlugin))
.add_plugins(BevyMotionGfxPlugin)
.add_systems(Startup, (setup, vello_basic))
.add_systems(Update, timeline_movement)
.run();
Expand All @@ -31,7 +31,7 @@ fn vello_basic(mut commands: Commands) {
let rect = (
VelloRect::new(100.0, 100.0),
Fill::new().with_color(palette.get(ColorKey::Blue)),
Stroke::new(4.0).with_color(palette.get(ColorKey::Blue) * 1.5),
Stroke::new(4.0).with_color(palette.get(ColorKey::Blue).lighter(0.2)),
Transform::from_xyz(-200.0, 0.0, 0.0),
);
let id = commands
Expand All @@ -43,7 +43,7 @@ fn vello_basic(mut commands: Commands) {
let circle = (
VelloCircle::new(50.0),
Fill::new().with_color(palette.get(ColorKey::Purple)),
Stroke::new(4.0).with_color(palette.get(ColorKey::Purple) * 1.5),
Stroke::new(4.0).with_color(palette.get(ColorKey::Purple).lighter(0.2)),
Transform::from_xyz(200.0, 0.0, 0.0),
);
let id = commands
Expand Down

0 comments on commit bbd6a49

Please sign in to comment.