Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
djeedai committed Oct 28, 2023
2 parents 8b2c6e2 + 29e8c33 commit f19400f
Show file tree
Hide file tree
Showing 12 changed files with 91 additions and 83 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Fixed a panic when a TextLens tried to change a section that wasn't present.
- Fixed a panic when a `TextLens` tried to change a text section that wasn't present.

## [0.8.0] - 2023-07-12

### Changed

- Compatible with Bevy 0.11

## [0.7.0] - 2023-03-09

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ interpolation = "0.2"
bevy = { version = "0.11", default-features = false }

[dev-dependencies]
bevy-inspector-egui = "0.18"
bevy-inspector-egui = "0.19"

[[example]]
name = "menu"
Expand Down
46 changes: 23 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![Crate](https://img.shields.io/crates/v/bevy_tweening.svg)](https://crates.io/crates/bevy_tweening)
[![Build Status](https://github.com/djeedai/bevy_tweening/actions/workflows/ci.yaml/badge.svg)](https://github.com/djeedai/bevy_tweening/actions/workflows/ci.yaml)
[![Coverage Status](https://coveralls.io/repos/github/djeedai/bevy_tweening/badge.svg?branch=main&kill_cache=1)](https://coveralls.io/github/djeedai/bevy_tweening?branch=main)
[![Bevy tracking](https://img.shields.io/badge/Bevy%20tracking-v0.10-lightblue)](https://github.com/bevyengine/bevy/blob/main/docs/plugins_guidelines.md#main-branch-tracking)
[![Bevy tracking](https://img.shields.io/badge/Bevy%20tracking-v0.11-lightblue)](https://github.com/bevyengine/bevy/blob/main/docs/plugins_guidelines.md#main-branch-tracking)

Tweening animation plugin for the Bevy game engine.

Expand All @@ -24,7 +24,7 @@ Add to `Cargo.toml`:

```toml
[dependencies]
bevy_tweening = "0.7"
bevy_tweening = "0.8"
```

This crate supports the following features:
Expand All @@ -43,7 +43,7 @@ Add the `TweeningPlugin` to your app:
```rust
App::default()
.add_plugins(DefaultPlugins)
.add_plugin(TweeningPlugin)
.add_plugins(TweeningPlugin)
.run();
```

Expand Down Expand Up @@ -115,30 +115,30 @@ The naming scheme for predefined lenses is `"<TargetName><FieldName>Lens"`, wher

| Target Component | Animated Field | Lens | Feature |
|---|---|---|---|
| [`Transform`](https://docs.rs/bevy/0.10.0/bevy/transform/components/struct.Transform.html) | [`translation`](https://docs.rs/bevy/0.10.0/bevy/transform/components/struct.Transform.html#structfield.translation) | [`TransformPositionLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/lens/struct.TransformPositionLens.html) | |
| | [`rotation`](https://docs.rs/bevy/0.10.0/bevy/transform/components/struct.Transform.html#structfield.rotation) (`Quat`| [`TransformRotationLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/lens/struct.TransformRotationLens.html) | |
| | [`rotation`](https://docs.rs/bevy/0.10.0/bevy/transform/components/struct.Transform.html#structfield.rotation) (angle)² | [`TransformRotateXLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/lens/struct.TransformRotateXLens.html) | |
| | [`rotation`](https://docs.rs/bevy/0.10.0/bevy/transform/components/struct.Transform.html#structfield.rotation) (angle)² | [`TransformRotateYLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/lens/struct.TransformRotateYLens.html) | |
| | [`rotation`](https://docs.rs/bevy/0.10.0/bevy/transform/components/struct.Transform.html#structfield.rotation) (angle)² | [`TransformRotateZLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/lens/struct.TransformRotateZLens.html) | |
| | [`rotation`](https://docs.rs/bevy/0.10.0/bevy/transform/components/struct.Transform.html#structfield.rotation) (angle)² | [`TransformRotateAxisLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/lens/struct.TransformRotateAxisLens.html) | |
| | [`scale`](https://docs.rs/bevy/0.10.0/bevy/transform/components/struct.Transform.html#structfield.scale) | [`TransformScaleLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/lens/struct.TransformScaleLens.html) | |
| [`Sprite`](https://docs.rs/bevy/0.10.0/bevy/sprite/struct.Sprite.html) | [`color`](https://docs.rs/bevy/0.10.0/bevy/sprite/struct.Sprite.html#structfield.color) | [`SpriteColorLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/lens/struct.SpriteColorLens.html) | `bevy_sprite` |
| [`Style`](https://docs.rs/bevy/0.10.0/bevy/ui/struct.Style.html) | [`position`](https://docs.rs/bevy/0.10.0/bevy/ui/struct.Style.html#structfield.position) | [`UiPositionLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/lens/struct.UiPositionLens.html) | `bevy_ui` |
| [`Text`](https://docs.rs/bevy/0.10.0/bevy/text/struct.Text.html) | [`TextStyle::color`](https://docs.rs/bevy/0.10.0/bevy/text/struct.TextStyle.html#structfield.color) | [`TextColorLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/lens/struct.TextColorLens.html) | `bevy_text` |
| [`Transform`](https://docs.rs/bevy/0.11.0/bevy/transform/components/struct.Transform.html) | [`translation`](https://docs.rs/bevy/0.11.0/bevy/transform/components/struct.Transform.html#structfield.translation) | [`TransformPositionLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/lens/struct.TransformPositionLens.html) | |
| | [`rotation`](https://docs.rs/bevy/0.11.0/bevy/transform/components/struct.Transform.html#structfield.rotation) (`Quat`| [`TransformRotationLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/lens/struct.TransformRotationLens.html) | |
| | [`rotation`](https://docs.rs/bevy/0.11.0/bevy/transform/components/struct.Transform.html#structfield.rotation) (angle)² | [`TransformRotateXLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/lens/struct.TransformRotateXLens.html) | |
| | [`rotation`](https://docs.rs/bevy/0.11.0/bevy/transform/components/struct.Transform.html#structfield.rotation) (angle)² | [`TransformRotateYLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/lens/struct.TransformRotateYLens.html) | |
| | [`rotation`](https://docs.rs/bevy/0.11.0/bevy/transform/components/struct.Transform.html#structfield.rotation) (angle)² | [`TransformRotateZLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/lens/struct.TransformRotateZLens.html) | |
| | [`rotation`](https://docs.rs/bevy/0.11.0/bevy/transform/components/struct.Transform.html#structfield.rotation) (angle)² | [`TransformRotateAxisLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/lens/struct.TransformRotateAxisLens.html) | |
| | [`scale`](https://docs.rs/bevy/0.11.0/bevy/transform/components/struct.Transform.html#structfield.scale) | [`TransformScaleLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/lens/struct.TransformScaleLens.html) | |
| [`Sprite`](https://docs.rs/bevy/0.11.0/bevy/sprite/struct.Sprite.html) | [`color`](https://docs.rs/bevy/0.11.0/bevy/sprite/struct.Sprite.html#structfield.color) | [`SpriteColorLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/lens/struct.SpriteColorLens.html) | `bevy_sprite` |
| [`Style`](https://docs.rs/bevy/0.11.0/bevy/ui/struct.Style.html) | [`position`](https://docs.rs/bevy/0.11.0/bevy/ui/struct.Style.html#structfield.position) | [`UiPositionLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/lens/struct.UiPositionLens.html) | `bevy_ui` |
| [`Text`](https://docs.rs/bevy/0.11.0/bevy/text/struct.Text.html) | [`TextStyle::color`](https://docs.rs/bevy/0.11.0/bevy/text/struct.TextStyle.html#structfield.color) | [`TextColorLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/lens/struct.TextColorLens.html) | `bevy_text` |

¹ Shortest-path interpolation between two rotations, using `Quat::slerp()`.

² Angle-based interpolation, valid for rotations over ½ turn.

See the [comparison of rotation lenses](https://docs.rs/bevy_tweening/0.4.0/bevy_tweening/lens/index.html#rotations) for details.
See the [comparison of rotation lenses](https://docs.rs/bevy_tweening/0.7.0/bevy_tweening/lens/index.html#rotations) for details.

### Bevy Assets

Asset animation always requires the `bevy_asset` feature.

| Target Asset | Animated Field | Lens | Feature |
|---|---|---|---|
| [`ColorMaterial`](https://docs.rs/bevy/0.10.0/bevy/sprite/struct.ColorMaterial.html) | [`color`](https://docs.rs/bevy/0.10.0/bevy/sprite/struct.ColorMaterial.html#structfield.color) | [`ColorMaterialColorLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/lens/struct.ColorMaterialColorLens.html) | `bevy_asset` + `bevy_sprite` |
| [`ColorMaterial`](https://docs.rs/bevy/0.11.0/bevy/sprite/struct.ColorMaterial.html) | [`color`](https://docs.rs/bevy/0.11.0/bevy/sprite/struct.ColorMaterial.html#structfield.color) | [`ColorMaterialColorLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/lens/struct.ColorMaterialColorLens.html) | `bevy_asset` + `bevy_sprite` |

## Custom lens

Expand Down Expand Up @@ -196,63 +196,63 @@ The process is similar to custom components, creating a custom lens for the cust

## Examples

See the [`examples/`](https://github.com/djeedai/bevy_tweening/tree/1bb14c4be46e0d3c8bc0233af3258b7a15c40793/examples) folder.
See the [`examples/`](https://github.com/djeedai/bevy_tweening/tree/cad68be96e492482cb6dfd395f07d4bc73d353bf/examples) folder.

### [`menu`](examples/menu.rs)

```rust
cargo run --example menu --features="bevy/bevy_winit"
```

![menu](https://raw.githubusercontent.com/djeedai/bevy_tweening/1bb14c4be46e0d3c8bc0233af3258b7a15c40793/examples/menu.gif)
![menu](https://raw.githubusercontent.com/djeedai/bevy_tweening/cad68be96e492482cb6dfd395f07d4bc73d353bf/examples/menu.gif)

### [`sprite_color`](examples/sprite_color.rs)

```rust
cargo run --example sprite_color --features="bevy/bevy_winit"
```

![sprite_color](https://raw.githubusercontent.com/djeedai/bevy_tweening/1bb14c4be46e0d3c8bc0233af3258b7a15c40793/examples/sprite_color.gif)
![sprite_color](https://raw.githubusercontent.com/djeedai/bevy_tweening/cad68be96e492482cb6dfd395f07d4bc73d353bf/examples/sprite_color.gif)

### [`transform_rotation`](examples/transform_rotation.rs)

```rust
cargo run --example transform_rotation --features="bevy/bevy_winit"
```

![sprite_color](https://raw.githubusercontent.com/djeedai/bevy_tweening/1bb14c4be46e0d3c8bc0233af3258b7a15c40793/examples/transform_rotation.gif)
![sprite_color](https://raw.githubusercontent.com/djeedai/bevy_tweening/cad68be96e492482cb6dfd395f07d4bc73d353bf/examples/transform_rotation.gif)

### [`transform_translation`](examples/transform_translation.rs)

```rust
cargo run --example transform_translation --features="bevy/bevy_winit"
```

![sprite_color](https://raw.githubusercontent.com/djeedai/bevy_tweening/1bb14c4be46e0d3c8bc0233af3258b7a15c40793/examples/transform_translation.gif)
![sprite_color](https://raw.githubusercontent.com/djeedai/bevy_tweening/cad68be96e492482cb6dfd395f07d4bc73d353bf/examples/transform_translation.gif)

### [`colormaterial_color`](examples/colormaterial_color.rs)

```rust
cargo run --example colormaterial_color --features="bevy/bevy_winit"
```

![colormaterial_color](https://raw.githubusercontent.com/djeedai/bevy_tweening/1bb14c4be46e0d3c8bc0233af3258b7a15c40793/examples/colormaterial_color.gif)
![colormaterial_color](https://raw.githubusercontent.com/djeedai/bevy_tweening/cad68be96e492482cb6dfd395f07d4bc73d353bf/examples/colormaterial_color.gif)

### [`ui_position`](examples/ui_position.rs)

```rust
cargo run --example ui_position --features="bevy/bevy_winit"
```

![ui_position](https://raw.githubusercontent.com/djeedai/bevy_tweening/1bb14c4be46e0d3c8bc0233af3258b7a15c40793/examples/ui_position.gif)
![ui_position](https://raw.githubusercontent.com/djeedai/bevy_tweening/cad68be96e492482cb6dfd395f07d4bc73d353bf/examples/ui_position.gif)

### [`sequence`](examples/sequence.rs)

```rust
cargo run --example sequence --features="bevy/bevy_winit"
```

![sequence](https://raw.githubusercontent.com/djeedai/bevy_tweening/1bb14c4be46e0d3c8bc0233af3258b7a15c40793/examples/sequence.gif)
![sequence](https://raw.githubusercontent.com/djeedai/bevy_tweening/cad68be96e492482cb6dfd395f07d4bc73d353bf/examples/sequence.gif)

## Ease Functions

Expand Down
6 changes: 3 additions & 3 deletions examples/colormaterial_color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ fn main() {
}),
..default()
}))
.add_system(bevy::window::close_on_esc)
.add_plugin(TweeningPlugin)
.add_startup_system(setup)
.add_systems(Update, bevy::window::close_on_esc)
.add_plugins(TweeningPlugin)
.add_systems(Startup, setup)
.run();
}

Expand Down
22 changes: 13 additions & 9 deletions examples/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ fn main() {
}),
..default()
}))
.add_system(bevy::window::close_on_esc)
.add_system(interaction)
.add_system(enable_interaction_after_initial_animation)
.add_plugin(TweeningPlugin)
.add_plugin(WorldInspectorPlugin::new())
.add_startup_system(setup)
.add_systems(Update, bevy::window::close_on_esc)
.add_systems(Update, interaction)
.add_systems(Update, enable_interaction_after_initial_animation)
.add_plugins(TweeningPlugin)
.add_plugins(WorldInspectorPlugin::new())
.add_systems(Startup, setup)
.run();
}

Expand All @@ -50,7 +50,10 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
NodeBundle {
style: Style {
position_type: PositionType::Absolute,
position: UiRect::all(Val::Px(0.)),
left: Val::Px(0.),
right: Val::Px(0.),
top: Val::Px(0.),
bottom: Val::Px(0.),
margin: UiRect::all(Val::Px(16.)),
padding: UiRect::all(Val::Px(16.)),
flex_direction: FlexDirection::Column,
Expand Down Expand Up @@ -95,7 +98,8 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
.spawn((
ButtonBundle {
style: Style {
min_size: Size::new(Val::Px(300.), Val::Px(80.)),
min_width: Val::Px(300.),
min_height: Val::Px(80.),
margin: UiRect::all(Val::Px(8.)),
padding: UiRect::all(Val::Px(8.)),
align_content: AlignContent::Center,
Expand Down Expand Up @@ -166,7 +170,7 @@ fn interaction(
) {
for (mut animator, transform, interaction, mut color, button_label) in &mut interaction_query {
match *interaction {
Interaction::Clicked => {
Interaction::Pressed => {
*color = CLICK_COLOR.into();

match button_label {
Expand Down
8 changes: 4 additions & 4 deletions examples/sequence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ fn main() {
}),
..default()
}))
.add_system(bevy::window::close_on_esc)
.add_plugin(TweeningPlugin)
.add_startup_system(setup)
.add_system(update_text)
.add_systems(Update, bevy::window::close_on_esc)
.add_plugins(TweeningPlugin)
.add_systems(Startup, setup)
.add_systems(Update, update_text)
.run();
}

Expand Down
6 changes: 3 additions & 3 deletions examples/sprite_color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ fn main() {
}),
..default()
}))
.add_system(bevy::window::close_on_esc)
.add_plugin(TweeningPlugin)
.add_startup_system(setup)
.add_systems(Update, bevy::window::close_on_esc)
.add_plugins(TweeningPlugin)
.add_systems(Startup, setup)
.run();
}

Expand Down
19 changes: 9 additions & 10 deletions examples/text_color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ fn main() {
}),
..default()
}))
.add_system(bevy::window::close_on_esc)
.add_plugin(TweeningPlugin)
.add_startup_system(setup)
.add_systems(Update, bevy::window::close_on_esc)
.add_plugins(TweeningPlugin)
.add_systems(Startup, setup)
.run();
}

Expand Down Expand Up @@ -83,13 +83,12 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
commands.spawn((
TextBundle {
style: Style {
size: Size::new(Val::Px(size_x), Val::Px(size_y)),
position: UiRect {
left: Val::Px(x),
top: Val::Px(y),
right: Val::Auto,
bottom: Val::Auto,
},
width: Val::Px(size_x),
height: Val::Px(size_y),
left: Val::Px(x),
top: Val::Px(y),
right: Val::Auto,
bottom: Val::Auto,
position_type: PositionType::Absolute,
align_content: AlignContent::Center,
align_items: AlignItems::Center,
Expand Down
10 changes: 5 additions & 5 deletions examples/transform_rotation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ fn main() {
..default()
}))
.init_resource::<Options>()
.add_system(bevy::window::close_on_esc)
.add_plugin(TweeningPlugin)
.add_plugin(ResourceInspectorPlugin::<Options>::new())
.add_startup_system(setup)
.add_system(update_animation_speed)
.add_systems(Update, bevy::window::close_on_esc)
.add_plugins(TweeningPlugin)
.add_plugins(ResourceInspectorPlugin::<Options>::new())
.add_systems(Startup, setup)
.add_systems(Update, update_animation_speed)
.run();
}

Expand Down
10 changes: 5 additions & 5 deletions examples/transform_translation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ fn main() {
..default()
}))
.init_resource::<Options>()
.add_system(bevy::window::close_on_esc)
.add_plugin(TweeningPlugin)
.add_plugin(ResourceInspectorPlugin::<Options>::default())
.add_startup_system(setup)
.add_system(update_animation_speed)
.add_systems(Update, bevy::window::close_on_esc)
.add_plugins(TweeningPlugin)
.add_plugins(ResourceInspectorPlugin::<Options>::default())
.add_systems(Startup, setup)
.add_systems(Update, update_animation_speed)
.run();
}

Expand Down
23 changes: 11 additions & 12 deletions examples/ui_position.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ fn main() {
..default()
}))
.init_resource::<Options>()
.add_system(bevy::window::close_on_esc)
.add_plugin(TweeningPlugin)
.add_plugin(ResourceInspectorPlugin::<Options>::new())
.add_startup_system(setup)
.add_system(update_animation_speed)
.add_systems(Update, bevy::window::close_on_esc)
.add_plugins(TweeningPlugin)
.add_plugins(ResourceInspectorPlugin::<Options>::new())
.add_systems(Startup, setup)
.add_systems(Update, update_animation_speed)
.run();
}

Expand Down Expand Up @@ -101,13 +101,12 @@ fn setup(mut commands: Commands) {
commands.spawn((
NodeBundle {
style: Style {
size: Size::new(Val::Px(size), Val::Px(size)),
position: UiRect {
left: Val::Px(x),
top: Val::Px(10.),
right: Val::Auto,
bottom: Val::Auto,
},
width: Val::Px(size),
height: Val::Px(size),
left: Val::Px(x),
top: Val::Px(10.),
right: Val::Auto,
bottom: Val::Auto,
position_type: PositionType::Absolute,
align_content: AlignContent::Center,
align_items: AlignItems::Center,
Expand Down
Loading

0 comments on commit f19400f

Please sign in to comment.