Skip to content

Commit

Permalink
Merge branch 'main' into easings-label
Browse files Browse the repository at this point in the history
  • Loading branch information
mockersf authored Jun 8, 2024
2 parents 3ebd2b8 + e517536 commit d74da26
Show file tree
Hide file tree
Showing 15 changed files with 178 additions and 117 deletions.
11 changes: 8 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bevy_easings"
version = "0.13.1"
version = "0.14.0"
authors = ["François Mockers <[email protected]>"]
edition = "2021"
description = "Easing plugin for Bevy"
Expand All @@ -17,11 +17,11 @@ categories = ["game-development"]
interpolation = "0.3"

[dependencies.bevy]
version = "0.13"
version = "0.14.0-rc.2"
default-features = false

[dev-dependencies.bevy]
version = "0.13"
version = "0.14.0-rc.2"
default-features = false
features = ["bevy_render", "bevy_sprite", "bevy_ui"]

Expand All @@ -42,6 +42,11 @@ default = ["render", "sprite", "ui"]
"bevy/bevy_asset",
"bevy/bevy_core_pipeline",
"bevy/default_font",
"bevy/png",
# Should be removed once this is fixed in Bevy 0.14
"bevy/ktx2",
"bevy/zstd",
"bevy/bevy_pbr",
]

[[example]]
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

Easings on Bevy components using [interpolation](https://crates.io/crates/interpolation).

![menu example](https://raw.githubusercontent.com/vleue/bevy_easings/main/examples/menu.webp)

## Usage

### System setup
Expand Down Expand Up @@ -229,7 +231,8 @@ Many [ease functions](https://docs.rs/interpolation/0.2.0/interpolation/enum.Eas
|Bevy|bevy_easings|
|---|---|
|main|main|
|0.13|0.13|
|0.14|0.14|
|0.13|0.14|
|0.12|0.12|
|0.11|0.11|
|0.10|0.10|
Expand Down
4 changes: 2 additions & 2 deletions examples/chain.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bevy::prelude::*;
use bevy::{color::palettes, prelude::*};

use bevy_easings::*;

Expand All @@ -20,7 +20,7 @@ fn setup(mut commands: Commands) {
SpriteBundle {
sprite: Sprite {
custom_size: Some(Vec2::new(100., 100.)),
color: Color::RED,
color: palettes::basic::RED.into(),
..Default::default()
},
..Default::default()
Expand Down
4 changes: 2 additions & 2 deletions examples/controlled.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bevy::prelude::*;
use bevy::{color::palettes, prelude::*};

use bevy_easings::*;

Expand Down Expand Up @@ -85,7 +85,7 @@ fn setup(mut commands: Commands) {
SpriteBundle {
sprite: Sprite {
custom_size: Some(Vec2::new(CUBE_SIZE, CUBE_SIZE)),
color: Color::RED,
color: palettes::basic::RED.into(),
..Default::default()
},
..Default::default()
Expand Down
1 change: 0 additions & 1 deletion examples/custom_component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ fn setup(mut commands: Commands) {
},
..Default::default()
},
background_color: BackgroundColor(Color::RED),
..Default::default()
},
CustomComponent(0.)
Expand Down
4 changes: 2 additions & 2 deletions examples/pause.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bevy::prelude::*;
use bevy::{color::palettes, prelude::*};

use bevy_easings::*;

Expand All @@ -21,7 +21,7 @@ fn setup(mut commands: Commands) {
SpriteBundle {
sprite: Sprite {
custom_size: Some(Vec2::new(100., 100.)),
color: Color::RED,
color: palettes::basic::RED.into(),
..Default::default()
},
..Default::default()
Expand Down
4 changes: 2 additions & 2 deletions examples/react_on_end.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bevy::prelude::*;
use bevy::{color::palettes, prelude::*};

use bevy_easings::*;
use rand::Rng;
Expand Down Expand Up @@ -28,7 +28,7 @@ fn setup(mut commands: Commands, windows: Query<&Window>) {
SpriteBundle {
sprite: Sprite {
custom_size: Some(Vec2::new(100., 100.)),
color: Color::RED,
color: palettes::basic::RED.into(),
..Default::default()
},
..Default::default()
Expand Down
44 changes: 30 additions & 14 deletions examples/sprite_color.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bevy::prelude::*;
use bevy::{color::palettes, prelude::*};

use bevy_easings::*;

Expand All @@ -12,14 +12,14 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}

fn setup(mut commands: Commands) {
fn setup(mut commands: Commands, window: Query<&Window>) {
commands.spawn(Camera2dBundle::default());

let size = 100.;
let size = 140.;

let spacing = 1.25;
let screen_x = 570.;
let screen_y = 150.;
let spacing = 1.15;
let screen_x = window.single().width();
let screen_y = window.single().height();
let mut x = -screen_x;
let mut y = screen_y;

Expand Down Expand Up @@ -57,31 +57,47 @@ fn setup(mut commands: Commands) {
] {
commands.spawn((
SpriteBundle {
transform: Transform::from_translation(Vec3::new(x, y, 0.)),
transform: Transform::from_translation(Vec3::new(
x + size / 2.0,
y - size / 2.0,
0.,
)),
..Default::default()
},
Sprite {
custom_size: Some(Vec2::new(size, size)),
color: Color::RED,
color: palettes::basic::RED.into(),
..Default::default()
}
.ease_to(
Sprite {
custom_size: Some(Vec2::new(size, size)),
color: Color::BLUE,
color: palettes::basic::BLUE.into(),
..Default::default()
},
*ease_function,
bevy_easings::EasingType::PingPong {
duration: std::time::Duration::from_secs(1),
duration: std::time::Duration::from_secs(2),
pause: Some(std::time::Duration::from_millis(500)),
},
),
));
y -= size * spacing;
if y < -screen_y {
x += size * spacing;
y = screen_y;
commands.spawn(Text2dBundle {
text: Text::from_section(
format!("{:?}", ease_function),
TextStyle {
font_size: 20.0,
..default()
},
),
transform: Transform::from_translation(Vec3::new(x + size / 2.0, y - size / 2.0, 0.)),

..default()
});
x += size * spacing;
if x + size > screen_x {
x = -screen_x;
y -= size * spacing;
}
}
}
48 changes: 34 additions & 14 deletions examples/sprite_size.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bevy::prelude::*;
use bevy::{color::palettes, prelude::*};

use bevy_easings::*;

Expand All @@ -12,15 +12,15 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}

fn setup(mut commands: Commands) {
fn setup(mut commands: Commands, window: Query<&Window>) {
commands.spawn(Camera2dBundle::default());

let initial_size = 10.;
let final_size = 100.;
let final_size = 140.;

let spacing = 1.25;
let screen_x = 570.;
let screen_y = 150.;
let spacing = 1.15;
let screen_x = window.single().width();
let screen_y = window.single().height();
let mut x = -screen_x;
let mut y = screen_y;

Expand Down Expand Up @@ -58,31 +58,51 @@ fn setup(mut commands: Commands) {
] {
commands.spawn((
SpriteBundle {
transform: Transform::from_translation(Vec3::new(x, y, 0.)),
transform: Transform::from_translation(Vec3::new(
x + final_size / 2.0,
y - final_size / 2.0,
0.,
)),
..Default::default()
},
Sprite {
custom_size: Some(Vec2::new(initial_size, initial_size)),
color: Color::RED,
color: palettes::basic::RED.into(),
..Default::default()
}
.ease_to(
Sprite {
custom_size: Some(Vec2::new(final_size, final_size)),
color: Color::RED,
color: palettes::basic::RED.into(),
..Default::default()
},
*ease_function,
bevy_easings::EasingType::PingPong {
duration: std::time::Duration::from_secs(1),
duration: std::time::Duration::from_secs(2),
pause: Some(std::time::Duration::from_millis(500)),
},
),
));
y -= final_size * spacing;
if y < -screen_y {
x += final_size * spacing;
y = screen_y;
commands.spawn(Text2dBundle {
text: Text::from_section(
format!("{:?}", ease_function),
TextStyle {
font_size: 20.0,
..default()
},
),
transform: Transform::from_translation(Vec3::new(
x + final_size / 2.0,
y - final_size / 2.0,
0.,
)),

..default()
});
x += final_size * spacing;
if x + final_size > screen_x {
x = -screen_x;
y -= final_size * spacing;
}
}
}
4 changes: 2 additions & 2 deletions examples/transform_rotation.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bevy::prelude::*;
use bevy::{color::palettes, prelude::*};

use bevy_easings::*;

Expand Down Expand Up @@ -64,7 +64,7 @@ fn setup(mut commands: Commands) {
SpriteBundle {
sprite: Sprite {
custom_size: Some(Vec2::new(size, size)),
color: Color::RED,
color: palettes::basic::RED.into(),
..Default::default()
},
..Default::default()
Expand Down
10 changes: 5 additions & 5 deletions examples/transform_translation.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bevy::prelude::*;
use bevy::{color::palettes, prelude::*};

use bevy_easings::*;

Expand Down Expand Up @@ -58,7 +58,7 @@ fn setup(mut commands: Commands) {
SpriteBundle {
sprite: Sprite {
custom_size: Some(Vec2::new(size, size)),
color: Color::RED,
color: palettes::basic::RED.into(),
..Default::default()
},
..Default::default()
Expand All @@ -79,7 +79,7 @@ fn setup(mut commands: Commands) {
SpriteBundle {
sprite: Sprite {
custom_size: Some(Vec2::new(size, size)),
color: Color::RED,
color: palettes::basic::RED.into(),
..Default::default()
},
..Default::default()
Expand All @@ -99,7 +99,7 @@ fn setup(mut commands: Commands) {
SpriteBundle {
sprite: Sprite {
custom_size: Some(Vec2::new(size, size)),
color: Color::RED,
color: palettes::basic::RED.into(),
..Default::default()
},
..Default::default()
Expand All @@ -119,7 +119,7 @@ fn setup(mut commands: Commands) {
SpriteBundle {
sprite: Sprite {
custom_size: Some(Vec2::new(size, size)),
color: Color::RED,
color: palettes::basic::RED.into(),
..Default::default()
},
..Default::default()
Expand Down
8 changes: 4 additions & 4 deletions examples/ui_color.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bevy::prelude::*;
use bevy::{color::palettes, prelude::*};

use bevy_easings::*;

Expand Down Expand Up @@ -51,7 +51,7 @@ fn setup(mut commands: Commands) {
.enumerate()
{
commands.spawn((
ImageBundle {
NodeBundle {
style: Style {
width: Val::Percent(5.),
height: Val::Percent(8.),
Expand All @@ -61,8 +61,8 @@ fn setup(mut commands: Commands) {
},
..Default::default()
},
BackgroundColor(Color::RED).ease_to(
BackgroundColor(Color::BLUE),
BackgroundColor(palettes::basic::RED.into()).ease_to(
BackgroundColor(palettes::basic::BLUE.into()),
*ease_function,
bevy_easings::EasingType::PingPong {
duration: std::time::Duration::from_secs(1),
Expand Down
6 changes: 3 additions & 3 deletions examples/ui_style.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bevy::prelude::*;
use bevy::{color::palettes, prelude::*};

use bevy_easings::*;

Expand Down Expand Up @@ -51,8 +51,8 @@ fn setup(mut commands: Commands) {
.enumerate()
{
commands.spawn((
ImageBundle {
background_color: BackgroundColor(Color::RED),
NodeBundle {
background_color: BackgroundColor(palettes::basic::RED.into()),
..Default::default()
},
Style {
Expand Down
Loading

0 comments on commit d74da26

Please sign in to comment.