Skip to content

Commit

Permalink
v0.11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
djeedai committed Jul 8, 2024
1 parent ef7090c commit f08891c
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 45 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [0.11.0] - 2024-07-08

### Changed

- Compatible with Bevy 0.14
- `Lens::lerp()` now takes a `&mut dyn Targetable<T>` instead of `&mut T`.
This ensures the lens can skip change detection if needed.
`Targetable<T>` conceptually acts like a `Mut<T>`, but allows encapsulating assets too.
Expand Down
45 changes: 23 additions & 22 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.13-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.14-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.10"
bevy_tweening = "0.11"
```

This crate supports the following features:
Expand Down Expand Up @@ -144,17 +144,17 @@ The naming scheme for predefined lenses is `"<TargetName><FieldName>Lens"`, wher

| Target Component | Animated Field | Lens | Feature |
|---|---|---|---|
| [`Transform`](https://docs.rs/bevy/0.12.0/bevy/transform/components/struct.Transform.html) | [`translation`](https://docs.rs/bevy/0.12.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.12.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.12.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.12.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.12.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.12.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.12.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.12.0/bevy/sprite/struct.Sprite.html) | [`color`](https://docs.rs/bevy/0.12.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.12.0/bevy/ui/struct.Style.html) | [`position`](https://docs.rs/bevy/0.12.0/bevy/ui/struct.Style.html#structfield.position) | [`UiPositionLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/lens/struct.UiPositionLens.html) | `bevy_ui` |
| [`BackgroundColor`](https://docs.rs/bevy/0.12.0/bevy/ui/struct.BackgroundColor.html)| | [`UiBackgroundColorLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/lens/struct.UiBackgroundColorLens.html) | `bevy_ui` |
| [`Text`](https://docs.rs/bevy/0.12.0/bevy/text/struct.Text.html) | [`TextStyle::color`](https://docs.rs/bevy/0.12.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.14.0/bevy/transform/components/struct.Transform.html) | [`translation`](https://docs.rs/bevy/0.14.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.14.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.14.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.14.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.14.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.14.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.14.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.14.0/bevy/sprite/struct.Sprite.html) | [`color`](https://docs.rs/bevy/0.14.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.14.0/bevy/ui/struct.Style.html) | [`position`](https://docs.rs/bevy/0.14.0/bevy/ui/struct.Style.html#structfield.position) | [`UiPositionLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/lens/struct.UiPositionLens.html) | `bevy_ui` |
| [`BackgroundColor`](https://docs.rs/bevy/0.14.0/bevy/ui/struct.BackgroundColor.html)| | [`UiBackgroundColorLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/lens/struct.UiBackgroundColorLens.html) | `bevy_ui` |
| [`Text`](https://docs.rs/bevy/0.14.0/bevy/text/struct.Text.html) | [`TextStyle::color`](https://docs.rs/bevy/0.14.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()`.

Expand All @@ -168,7 +168,7 @@ Asset animation always requires the `bevy_asset` feature.

| Target Asset | Animated Field | Lens | Feature |
|---|---|---|---|
| [`ColorMaterial`](https://docs.rs/bevy/0.12.0/bevy/sprite/struct.ColorMaterial.html) | [`color`](https://docs.rs/bevy/0.12.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.14.0/bevy/sprite/struct.ColorMaterial.html) | [`color`](https://docs.rs/bevy/0.14.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 @@ -226,63 +226,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/77b89d9df5a28f66ae6b153e6d24cf0d58042353/examples) folder.
See the [`examples/`](https://github.com/djeedai/bevy_tweening/tree/ef7090cddd19971316ee1583076007f67ead6580/examples) folder.

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

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

![menu](https://raw.githubusercontent.com/djeedai/bevy_tweening/77b89d9df5a28f66ae6b153e6d24cf0d58042353/examples/menu.gif)
![menu](https://raw.githubusercontent.com/djeedai/bevy_tweening/ef7090cddd19971316ee1583076007f67ead6580/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/77b89d9df5a28f66ae6b153e6d24cf0d58042353/examples/sprite_color.gif)
![sprite_color](https://raw.githubusercontent.com/djeedai/bevy_tweening/ef7090cddd19971316ee1583076007f67ead6580/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/77b89d9df5a28f66ae6b153e6d24cf0d58042353/examples/transform_rotation.gif)
![sprite_color](https://raw.githubusercontent.com/djeedai/bevy_tweening/ef7090cddd19971316ee1583076007f67ead6580/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/77b89d9df5a28f66ae6b153e6d24cf0d58042353/examples/transform_translation.gif)
![sprite_color](https://raw.githubusercontent.com/djeedai/bevy_tweening/ef7090cddd19971316ee1583076007f67ead6580/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/77b89d9df5a28f66ae6b153e6d24cf0d58042353/examples/colormaterial_color.gif)
![colormaterial_color](https://raw.githubusercontent.com/djeedai/bevy_tweening/ef7090cddd19971316ee1583076007f67ead6580/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/77b89d9df5a28f66ae6b153e6d24cf0d58042353/examples/ui_position.gif)
![ui_position](https://raw.githubusercontent.com/djeedai/bevy_tweening/ef7090cddd19971316ee1583076007f67ead6580/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/77b89d9df5a28f66ae6b153e6d24cf0d58042353/examples/sequence.gif)
![sequence](https://raw.githubusercontent.com/djeedai/bevy_tweening/ef7090cddd19971316ee1583076007f67ead6580/examples/sequence.gif)

## Ease Functions

Expand Down Expand Up @@ -327,6 +327,7 @@ Compatibility of `bevy_tweening` versions:

| `bevy_tweening` | `bevy` |
| :-- | :-- |
| `0.11` | `0.14` |
| `0.10` | `0.13` |
| `0.9` | `0.12` |
| `0.8` | `0.11` |
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bevy_tweening_bench"
version = "0.10.0"
version = "0.11.0"
authors = ["Jerome Humbert <[email protected]>"]
edition = "2021"
description = "Tweening plugin for Bevy -- Benchmarks"
Expand Down
47 changes: 26 additions & 21 deletions src/tweenable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ impl<'a, T: Asset> AssetTarget<'a, T> {

/// Check if the current target is valid given the value of [`handle`].
///
/// [`handle`]: self::handle
/// [`handle`]: AssetTarget::handle
pub fn is_valid(&self) -> bool {
self.assets.contains(&self.handle)
}
Expand Down Expand Up @@ -583,9 +583,10 @@ impl<T> Tween<T> {

/// Enable running a one-shot system upon completion.
///
/// If enabled, the tween will run a system via a provided [`SystemId`] when the
/// animation completes. This is similar to the [`with_completed()`],
/// but uses a system registered by [`register_system()`] instead of a callback.
/// If enabled, the tween will run a system via a provided [`SystemId`] when
/// the animation completes. This is similar to the
/// [`with_completed()`], but uses a system registered by
/// [`register_system()`] instead of a callback.
///
/// # Example
///
Expand Down Expand Up @@ -716,9 +717,10 @@ impl<T> Tween<T> {

/// Enable running a one-shot system upon completion.
///
/// If enabled, the tween will run a system via a provided [`SystemId`] when the
/// animation completes. This is similar to the [`with_completed()`],
/// but uses a system registered by [`register_system()`] instead of a callback.
/// If enabled, the tween will run a system via a provided [`SystemId`] when
/// the animation completes. This is similar to the
/// [`with_completed()`], but uses a system registered by
/// [`register_system()`] instead of a callback.
///
/// [`with_completed()`]: Tween::with_completed
/// [`register_system()`]: bevy::ecs::world::World::register_system
Expand Down Expand Up @@ -1145,7 +1147,7 @@ impl<T> Delay<T> {
/// });
/// ```
///
/// [`with_completed_event()`]: Tween::with_completed_event
/// [`with_completed_event()`]: Delay::with_completed_event
pub fn with_completed<C>(mut self, callback: C) -> Self
where
C: Fn(Entity, &Self) + Send + Sync + 'static,
Expand All @@ -1156,9 +1158,10 @@ impl<T> Delay<T> {

/// Enable running a one-shot system upon completion.
///
/// If enabled, the tween will run a system via a provided [`SystemId`] when the
/// animation completes. This is similar to the [`with_completed()`],
/// but uses a system registered by [`register_system()`] instead.
/// If enabled, the tween will run a system via a provided [`SystemId`] when
/// the animation completes. This is similar to the
/// [`with_completed()`], but uses a system registered by
/// [`register_system()`] instead.
///
/// # Example
///
Expand Down Expand Up @@ -1186,7 +1189,7 @@ impl<T> Delay<T> {
/// }
/// ```
///
/// [`with_completed()`]: Tween::with_completed
/// [`with_completed()`]: Delay::with_completed
/// [`register_system()`]: bevy::ecs::world::World::register_system
#[must_use]
pub fn with_completed_system(mut self, system_id: SystemId) -> Self {
Expand Down Expand Up @@ -1226,7 +1229,7 @@ impl<T> Delay<T> {
///
/// See also [`set_completed()`].
///
/// [`set_completed()`]: Tween::set_completed
/// [`set_completed()`]: Delay::set_completed
pub fn clear_completed(&mut self) {
self.on_completed = None;
}
Expand All @@ -1239,8 +1242,8 @@ impl<T> Delay<T> {
///
/// See [`with_completed_event()`] for details.
///
/// [`set_completed()`]: Tween::set_completed
/// [`with_completed_event()`]: Tween::with_completed_event
/// [`set_completed()`]: Delay::set_completed
/// [`with_completed_event()`]: Delay::with_completed_event
pub fn set_completed_event(&mut self, user_data: u64) {
self.event_data = Some(user_data);
}
Expand All @@ -1249,20 +1252,22 @@ impl<T> Delay<T> {
///
/// See also [`set_completed_event()`].
///
/// [`set_completed_event()`]: Tween::set_completed_event
/// [`set_completed_event()`]: Delay::set_completed_event
pub fn clear_completed_event(&mut self) {
self.event_data = None;
}

/// Enable running a one-shot system upon completion.
///
/// If enabled, the tween will run a system via a provided [`SystemId`] when the
/// animation completes. This is similar to the [`with_completed()`],
/// but uses a system registered by [`register_system()`] instead of a callback.
/// If enabled, the tween will run a system via a provided [`SystemId`] when
/// the animation completes. This is similar to the
/// [`with_completed()`], but uses a system registered by
/// [`register_system()`] instead of a callback.
///
/// See [`with_completed_system()`] for details.
///
/// [`with_completed()`]: Tween::with_completed
/// [`with_completed()`]: Delay::with_completed
/// [`with_completed_system()`]: Delay::with_completed_system
/// [`register_system()`]: bevy::ecs::world::World::register_system
pub fn set_completed_system(&mut self, system_id: SystemId) {
self.system_id = Some(system_id);
Expand All @@ -1272,7 +1277,7 @@ impl<T> Delay<T> {
///
/// See also [`set_completed_system()`].
///
/// [`clear_completed_system()`]: Tween::clear_completed_system
/// [`set_completed_system()`]: Delay::set_completed_system
pub fn clear_completed_system(&mut self) {
self.system_id = None;
}
Expand Down

0 comments on commit f08891c

Please sign in to comment.