All Projects → vleue → bevy_easings

vleue / bevy_easings

Licence: other
Helpers and Plugins for Bevy

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to bevy easings

SwiftTweener
A pure Swift animation engine.
Stars: ✭ 74 (-10.84%)
Mutual labels:  tweening, easing
bevy kira audio
A Bevy plugin to use Kira for game audio
Stars: ✭ 99 (+19.28%)
Mutual labels:  bevy, bevy-plugin
bevy prototype networking laminar
This is a prototype of a networking crate for bevy. This create provides a low-level networking plugin built on top of laminar
Stars: ✭ 30 (-63.86%)
Mutual labels:  bevy
bevy verlet
Verlet physics plugin for bevy.
Stars: ✭ 29 (-65.06%)
Mutual labels:  bevy-plugin
rgis
Performant, cross-platform (web, desktop) GIS app written in Rust
Stars: ✭ 79 (-4.82%)
Mutual labels:  bevy
interpolations
Lightweight Unity library for smoothing movements and value progressions in code (dragging, easing, tweening).
Stars: ✭ 29 (-65.06%)
Mutual labels:  tweening
bevy retrograde
Plugin pack for making 2D games with Bevy
Stars: ✭ 212 (+155.42%)
Mutual labels:  bevy
bevy mod bounding
Unofficial plugin for generating bounding boxes in Bevy
Stars: ✭ 21 (-74.7%)
Mutual labels:  bevy
rust-easing
Tiny Rust library implementing Robert Penner's easing functions
Stars: ✭ 17 (-79.52%)
Mutual labels:  easing
anim8js
The ultimate animation library for javascript - animate everything!
Stars: ✭ 33 (-60.24%)
Mutual labels:  easing
bevy 4x camera
A 4X style camera for bevy.
Stars: ✭ 26 (-68.67%)
Mutual labels:  bevy
bevy template
Compile-time optimized Bevy project template
Stars: ✭ 27 (-67.47%)
Mutual labels:  bevy
kinieta
A Fast Animation Engine with an Intuitive API
Stars: ✭ 44 (-46.99%)
Mutual labels:  tweening
PhaserCHOP
A TouchDesigner channel operator for phase-staggered animations
Stars: ✭ 15 (-81.93%)
Mutual labels:  easing
FluentTransitions
▶ Smooth UI animations & transitions for .NET
Stars: ✭ 27 (-67.47%)
Mutual labels:  tweening
duck-tween
A tween library for unity
Stars: ✭ 23 (-72.29%)
Mutual labels:  tweening
bevy config cam
A Swiss Army knife of a camera plugin that allows for easy setup and configuration of a wide variety of types of moveable cameras and player cameras for a scene.
Stars: ✭ 155 (+86.75%)
Mutual labels:  bevy
custom-easings-with-keyframes
🏃 Make custom non-cubic-bezier easings using keyframes and animations with this online css code generator.
Stars: ✭ 15 (-81.93%)
Mutual labels:  easing
ux-animate
A simple but powerful tweening, spring physics, animation library for Rust
Stars: ✭ 19 (-77.11%)
Mutual labels:  tweening
utils.js
👷 🔧 zero dependencies vanilla JavaScript utils.
Stars: ✭ 14 (-83.13%)
Mutual labels:  easing

Bevy Easings

MIT/Apache 2.0 Doc Crate Bevy Tracking CI

Easings on Bevy components using interpolation.

Usage

System setup

Add the plugin to your app:

use bevy::prelude::*;
use bevy_easings::EasingsPlugin;

fn main() {
    App::new()
        .add_plugin(EasingsPlugin);
}

Easing a component to a new value

And then just ease your components to their new state!

use bevy::prelude::*;
use bevy_easings::*;

fn my_system(mut commands: Commands){
    commands
        .spawn_bundle(SpriteBundle {
            ..Default::default()
        })
        .insert(
            Sprite {
                custom_size: Some(Vec2::new(10., 10.)),
                ..Default::default()
            }
            .ease_to(
                Sprite {
                    custom_size: Some(Vec2::new(100., 100.)),
                    ..Default::default()
                },
                EaseFunction::QuadraticIn,
                EasingType::PingPong {
                    duration: std::time::Duration::from_secs(1),
                    pause: Some(std::time::Duration::from_millis(500)),
                },
            ),
        );
}

If the component being eased is not already a component of the entity, the component should first be inserted for the target entity.

Chaining easing

You can chain easings, if they are not set to repeat they will happen in sequence.

use bevy::prelude::*;
use bevy_easings::*;

fn my_system(mut commands: Commands){
    commands
        .spawn_bundle(SpriteBundle {
            ..Default::default()
        })
        .insert(
            Sprite {
                custom_size: Some(Vec2::new(10., 10.)),
                ..Default::default()
            }
            .ease_to(
                Sprite {
                    custom_size: Some(Vec2::new(300., 300.)),
                    ..Default::default()
                },
                EaseFunction::QuadraticIn,
                EasingType::Once {
                    duration: std::time::Duration::from_secs(1),
                },
            )
            .ease_to(
                Sprite {
                    custom_size: Some(Vec2::new(350., 350.)),
                    ..Default::default()
                },
                EaseFunction::QuadraticIn,
                EasingType::PingPong {
                    duration: std::time::Duration::from_millis(500),
                    pause: Some(std::time::Duration::from_millis(200)),
                },
            ),
        );
}

Bundle Supported

Custom component support

To be able to ease a component, it needs to implement the traits Default and Lerp. This trait is re-exported by beavy_easings.

use bevy::prelude::*;
use bevy_easings::*;

#[derive(Default, Component)]
struct CustomComponent(f32);
impl Lerp for CustomComponent {
    type Scalar = f32;

    fn lerp(&self, other: &Self, scalar: &Self::Scalar) -> Self {
        CustomComponent(interpolation::lerp(&self.0, &other.0, scalar))
    }
}

The basic formula for lerp (linear interpolation) is self + (other - self) * scalar.

Then, the system custom_ease_system::<CustomComponent> needs to be added to the application.

Examples

See examples

sprite_color

sprite_size

transform_rotation

transform_translation

Ease Functions

Many ease functions are available:

  • QuadraticIn
  • QuadraticOut
  • QuadraticInOut
  • CubicIn
  • CubicOut
  • CubicInOut
  • QuarticIn
  • QuarticOut
  • QuarticInOut
  • QuinticIn
  • QuinticOut
  • QuinticInOut
  • SineIn
  • SineOut
  • SineInOut
  • CircularIn
  • CircularOut
  • CircularInOut
  • ExponentialIn
  • ExponentialOut
  • ExponentialInOut
  • ElasticIn
  • ElasticOut
  • ElasticInOut
  • BackIn
  • BackOut
  • BackInOut
  • BounceIn
  • BounceOut
  • BounceInOut
Bevy bevy_easings
main main
0.7 0.7
0.6 0.6
0.5 0.4
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].