Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
mockersf authored Nov 14, 2024
2 parents b320982 + 33e4444 commit f5a815f
Show file tree
Hide file tree
Showing 17 changed files with 219 additions and 396 deletions.
76 changes: 17 additions & 59 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bevy_easings"
version = "0.14.0"
version = "0.15.0-rc.1"
authors = ["François Mockers <[email protected]>"]
edition = "2021"
description = "Easing plugin for Bevy"
Expand All @@ -17,13 +17,26 @@ categories = ["game-development"]
interpolation = "0.3"

[dependencies.bevy]
version = "0.14.0"
version = "0.15.0-rc.3"
default-features = false

[dev-dependencies.bevy]
version = "0.14.0"
version = "0.15.0-rc.3"
default-features = false
features = ["bevy_render", "bevy_sprite", "bevy_ui"]
features = [
"bevy_render",
"bevy_sprite",
"bevy_ui",
"bevy_text",
"bevy_sprite",
"bevy_render",
"bevy_winit",
"x11",
"bevy_asset",
"bevy_core_pipeline",
"default_font",
"png",
]

[dev-dependencies]
rand = "0.8"
Expand All @@ -33,58 +46,3 @@ default = ["render", "sprite", "ui"]
"render" = ["bevy/bevy_render"]
"sprite" = ["bevy/bevy_sprite"]
"ui" = ["bevy/bevy_ui"]
"examples" = [
"ui",
"sprite",
"render",
"bevy/bevy_winit",
"bevy/x11",
"bevy/bevy_asset",
"bevy/bevy_core_pipeline",
"bevy/default_font",
"bevy/png",
]

[[example]]
name = "chain"
required-features = ["examples"]

[[example]]
name = "react_on_end"
required-features = ["examples"]

[[example]]
name = "sprite_color"
required-features = ["examples"]

[[example]]
name = "custom_component"
required-features = ["examples"]

[[example]]
name = "pause"
required-features = ["examples"]

[[example]]
name = "sprite_size"
required-features = ["examples"]

[[example]]
name = "transform_rotation"
required-features = ["examples"]

[[example]]
name = "transform_translation"
required-features = ["examples"]

[[example]]
name = "ui_style"
required-features = ["examples"]

[[example]]
name = "ui_color"
required-features = ["examples"]

[[example]]
name = "controlled"
required-features = ["examples"]
29 changes: 15 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ And then just ease your components to their new state!

```rust
use bevy::prelude::*;
use bevy_easings::*;
use bevy_easings::Ease;

fn my_system(mut commands: Commands){
commands
.spawn((
SpriteBundle {
Sprite {
..Default::default()
},
Sprite {
Expand All @@ -49,8 +49,8 @@ fn my_system(mut commands: Commands){
custom_size: Some(Vec2::new(100., 100.)),
..Default::default()
},
EaseFunction::QuadraticIn,
EasingType::PingPong {
bevy_easings::EaseFunction::QuadraticIn,
bevy_easings::EasingType::PingPong {
duration: std::time::Duration::from_secs(1),
pause: Some(std::time::Duration::from_millis(500)),
},
Expand Down Expand Up @@ -82,12 +82,12 @@ This is shown below

```rust
use bevy::prelude::*;
use bevy_easings::*;
use bevy_easings::Ease;

fn my_system(mut commands: Commands){
commands
.spawn((
SpriteBundle {
Sprite {
..Default::default()
},
Sprite {
Expand All @@ -99,8 +99,8 @@ fn my_system(mut commands: Commands){
custom_size: Some(Vec2::new(100., 100.)),
..Default::default()
},
EaseMethod::Linear,
EasingType::PingPong {
bevy_easings::EaseMethod::Linear,
bevy_easings::EasingType::PingPong {
duration: std::time::Duration::from_secs(1),
pause: Some(std::time::Duration::from_millis(500)),
},
Expand All @@ -115,12 +115,12 @@ You can chain easings, if they are not set to repeat they will happen in sequenc

```rust
use bevy::prelude::*;
use bevy_easings::*;
use bevy_easings::Ease;

fn my_system(mut commands: Commands){
commands
.spawn((
SpriteBundle {
Sprite {
..Default::default()
},
Sprite {
Expand All @@ -132,8 +132,8 @@ fn my_system(mut commands: Commands){
custom_size: Some(Vec2::new(300., 300.)),
..Default::default()
},
EaseFunction::QuadraticIn,
EasingType::Once {
bevy_easings::EaseFunction::QuadraticIn,
bevy_easings::EasingType::Once {
duration: std::time::Duration::from_secs(1),
},
)
Expand All @@ -142,8 +142,8 @@ fn my_system(mut commands: Commands){
custom_size: Some(Vec2::new(350., 350.)),
..Default::default()
},
EaseFunction::QuadraticIn,
EasingType::PingPong {
bevy_easings::EaseFunction::QuadraticIn,
bevy_easings::EasingType::PingPong {
duration: std::time::Duration::from_millis(500),
pause: Some(std::time::Duration::from_millis(200)),
},
Expand Down Expand Up @@ -229,6 +229,7 @@ Many [ease functions](https://docs.rs/interpolation/0.2.0/interpolation/enum.Eas
|Bevy|bevy_easings|
|---|---|
|main|main|
|0.15|0.15|
|0.14|0.14|
|0.13|0.14|
|0.12|0.12|
Expand Down
13 changes: 3 additions & 10 deletions examples/chain.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use bevy::{color::palettes, prelude::*};

use bevy_easings::*;
use bevy_easings::{Ease, *};

fn main() -> Result<(), Box<dyn std::error::Error>> {
App::default()
Expand All @@ -14,17 +14,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
}

fn setup(mut commands: Commands) {
commands.spawn(Camera2dBundle::default());
commands.spawn(Camera2d);

commands.spawn((
SpriteBundle {
sprite: Sprite {
custom_size: Some(Vec2::new(100., 100.)),
color: palettes::basic::RED.into(),
..Default::default()
},
..Default::default()
},
Sprite::from_color(palettes::basic::RED, Vec2::new(100., 100.)),
Transform::from_scale(Vec3::ZERO)
.ease_to(
Transform::from_scale(Vec3::splat(2.0)),
Expand Down
105 changes: 47 additions & 58 deletions examples/controlled.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use bevy::{color::palettes, prelude::*};
use bevy::{color::palettes, prelude::*, sprite::Anchor};

use bevy_easings::*;
use bevy_easings::{Ease, *};

const CUBE_SIZE: f32 = 25.;

Expand Down Expand Up @@ -28,36 +28,36 @@ impl Default for EasingList {
fn default() -> Self {
Self(vec![
EaseMethod::Linear,
EaseMethod::EaseFunction(EaseFunction::QuadraticIn),
EaseMethod::EaseFunction(EaseFunction::QuadraticOut),
EaseMethod::EaseFunction(EaseFunction::QuadraticInOut),
EaseMethod::EaseFunction(EaseFunction::CubicIn),
EaseMethod::EaseFunction(EaseFunction::CubicOut),
EaseMethod::EaseFunction(EaseFunction::CubicInOut),
EaseMethod::EaseFunction(EaseFunction::QuarticIn),
EaseMethod::EaseFunction(EaseFunction::QuarticOut),
EaseMethod::EaseFunction(EaseFunction::QuarticInOut),
EaseMethod::EaseFunction(EaseFunction::QuinticIn),
EaseMethod::EaseFunction(EaseFunction::QuinticOut),
EaseMethod::EaseFunction(EaseFunction::QuinticInOut),
EaseMethod::EaseFunction(EaseFunction::SineIn),
EaseMethod::EaseFunction(EaseFunction::SineOut),
EaseMethod::EaseFunction(EaseFunction::SineInOut),
EaseMethod::EaseFunction(EaseFunction::CircularIn),
EaseMethod::EaseFunction(EaseFunction::CircularOut),
EaseMethod::EaseFunction(EaseFunction::CircularInOut),
EaseMethod::EaseFunction(EaseFunction::ExponentialIn),
EaseMethod::EaseFunction(EaseFunction::ExponentialOut),
EaseMethod::EaseFunction(EaseFunction::ExponentialInOut),
EaseMethod::EaseFunction(EaseFunction::ElasticIn),
EaseMethod::EaseFunction(EaseFunction::ElasticOut),
EaseMethod::EaseFunction(EaseFunction::ElasticInOut),
EaseMethod::EaseFunction(EaseFunction::BackIn),
EaseMethod::EaseFunction(EaseFunction::BackOut),
EaseMethod::EaseFunction(EaseFunction::BackInOut),
EaseMethod::EaseFunction(EaseFunction::BounceIn),
EaseMethod::EaseFunction(EaseFunction::BounceOut),
EaseMethod::EaseFunction(EaseFunction::BounceInOut),
EaseMethod::EaseFunction(bevy_easings::EaseFunction::QuadraticIn),
EaseMethod::EaseFunction(bevy_easings::EaseFunction::QuadraticOut),
EaseMethod::EaseFunction(bevy_easings::EaseFunction::QuadraticInOut),
EaseMethod::EaseFunction(bevy_easings::EaseFunction::CubicIn),
EaseMethod::EaseFunction(bevy_easings::EaseFunction::CubicOut),
EaseMethod::EaseFunction(bevy_easings::EaseFunction::CubicInOut),
EaseMethod::EaseFunction(bevy_easings::EaseFunction::QuarticIn),
EaseMethod::EaseFunction(bevy_easings::EaseFunction::QuarticOut),
EaseMethod::EaseFunction(bevy_easings::EaseFunction::QuarticInOut),
EaseMethod::EaseFunction(bevy_easings::EaseFunction::QuinticIn),
EaseMethod::EaseFunction(bevy_easings::EaseFunction::QuinticOut),
EaseMethod::EaseFunction(bevy_easings::EaseFunction::QuinticInOut),
EaseMethod::EaseFunction(bevy_easings::EaseFunction::SineIn),
EaseMethod::EaseFunction(bevy_easings::EaseFunction::SineOut),
EaseMethod::EaseFunction(bevy_easings::EaseFunction::SineInOut),
EaseMethod::EaseFunction(bevy_easings::EaseFunction::CircularIn),
EaseMethod::EaseFunction(bevy_easings::EaseFunction::CircularOut),
EaseMethod::EaseFunction(bevy_easings::EaseFunction::CircularInOut),
EaseMethod::EaseFunction(bevy_easings::EaseFunction::ExponentialIn),
EaseMethod::EaseFunction(bevy_easings::EaseFunction::ExponentialOut),
EaseMethod::EaseFunction(bevy_easings::EaseFunction::ExponentialInOut),
EaseMethod::EaseFunction(bevy_easings::EaseFunction::ElasticIn),
EaseMethod::EaseFunction(bevy_easings::EaseFunction::ElasticOut),
EaseMethod::EaseFunction(bevy_easings::EaseFunction::ElasticInOut),
EaseMethod::EaseFunction(bevy_easings::EaseFunction::BackIn),
EaseMethod::EaseFunction(bevy_easings::EaseFunction::BackOut),
EaseMethod::EaseFunction(bevy_easings::EaseFunction::BackInOut),
EaseMethod::EaseFunction(bevy_easings::EaseFunction::BounceIn),
EaseMethod::EaseFunction(bevy_easings::EaseFunction::BounceOut),
EaseMethod::EaseFunction(bevy_easings::EaseFunction::BounceInOut),
])
}
}
Expand All @@ -77,19 +77,12 @@ impl Default for AnimatedCube {
}

fn setup(mut commands: Commands) {
commands.spawn(Camera2dBundle::default());
commands.spawn(Camera2d);

let default_cube = AnimatedCube::default();

commands.spawn((
SpriteBundle {
sprite: Sprite {
custom_size: Some(Vec2::new(CUBE_SIZE, CUBE_SIZE)),
color: palettes::basic::RED.into(),
..Default::default()
},
..Default::default()
},
Sprite::from_color(palettes::basic::RED, Vec2::new(CUBE_SIZE, CUBE_SIZE)),
create_animated_transform(
-SCREEN_X,
SCREEN_Y,
Expand All @@ -101,20 +94,15 @@ fn setup(mut commands: Commands) {
default_cube,
));

commands.spawn((Text2dBundle {
text: Text::from_section(
format_info_text(&Vec3::ZERO, 0, None, EaseMethod::Linear),
TextStyle {
color: Color::WHITE,
font_size: 18.0,
..default()
},
)
.with_justify(JustifyText::Right),
transform: Transform::from_translation(Vec3::new(SCREEN_X, 15., 0.)),
text_anchor: bevy::sprite::Anchor::CenterRight,
..Default::default()
},));
commands.spawn((
Text2d::new("".to_string()),
TextFont {
font_size: 18.0,
..default()
},
Transform::from_translation(Vec3::new(SCREEN_X, 15., 0.)),
Anchor::CenterRight,
));
}

fn handle_input(
Expand Down Expand Up @@ -182,15 +170,16 @@ fn check_value(cube_query: Query<&Transform, Changed<Transform>>) {
}

fn update_text(
mut text_query: Query<&mut Text>,
text_query: Query<Entity, With<Text2d>>,
ease_functions: Res<EasingList>,
cube_query: Query<(Entity, &Transform, &AnimatedCube)>,
anim_query: Query<&EasingComponent<Transform>, With<AnimatedCube>>,
mut text_writer: Text2dWriter,
) {
for (entity, transform, animated_cube) in cube_query.iter() {
for mut text in text_query.iter_mut() {
for text in &text_query {
let easing_state = anim_query.get(entity).map(|anim| anim.state).ok();
text.sections[0].value = format_info_text(
*text_writer.text(text, 0) = format_info_text(
&transform.translation,
animated_cube.duration,
easing_state,
Expand Down
Loading

0 comments on commit f5a815f

Please sign in to comment.