Add ease-out-quad curve

This commit is contained in:
Ivan Molodetskikh
2024-04-09 21:36:19 +04:00
parent 7e0d3d31f7
commit 209492e700
3 changed files with 11 additions and 2 deletions
+1
View File
@@ -611,6 +611,7 @@ impl EasingParams {
#[derive(knuffel::DecodeScalar, Debug, Clone, Copy, PartialEq)] #[derive(knuffel::DecodeScalar, Debug, Clone, Copy, PartialEq)]
pub enum AnimationCurve { pub enum AnimationCurve {
EaseOutQuad,
EaseOutCubic, EaseOutCubic,
EaseOutExpo, EaseOutExpo,
} }
+4 -1
View File
@@ -1,6 +1,6 @@
use std::time::Duration; use std::time::Duration;
use keyframe::functions::EaseOutCubic; use keyframe::functions::{EaseOutCubic, EaseOutQuad};
use keyframe::EasingFunction; use keyframe::EasingFunction;
use portable_atomic::{AtomicF64, Ordering}; use portable_atomic::{AtomicF64, Ordering};
@@ -35,6 +35,7 @@ enum Kind {
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
pub enum Curve { pub enum Curve {
EaseOutQuad,
EaseOutCubic, EaseOutCubic,
EaseOutExpo, EaseOutExpo,
} }
@@ -276,6 +277,7 @@ impl Animation {
impl Curve { impl Curve {
pub fn y(self, x: f64) -> f64 { pub fn y(self, x: f64) -> f64 {
match self { match self {
Curve::EaseOutQuad => EaseOutQuad.y(x),
Curve::EaseOutCubic => EaseOutCubic.y(x), Curve::EaseOutCubic => EaseOutCubic.y(x),
Curve::EaseOutExpo => 1. - 2f64.powf(-10. * x), Curve::EaseOutExpo => 1. - 2f64.powf(-10. * x),
} }
@@ -285,6 +287,7 @@ impl Curve {
impl From<niri_config::AnimationCurve> for Curve { impl From<niri_config::AnimationCurve> for Curve {
fn from(value: niri_config::AnimationCurve) -> Self { fn from(value: niri_config::AnimationCurve) -> Self {
match value { match value {
niri_config::AnimationCurve::EaseOutQuad => Curve::EaseOutQuad,
niri_config::AnimationCurve::EaseOutCubic => Curve::EaseOutCubic, niri_config::AnimationCurve::EaseOutCubic => Curve::EaseOutCubic,
niri_config::AnimationCurve::EaseOutExpo => Curve::EaseOutExpo, niri_config::AnimationCurve::EaseOutExpo => Curve::EaseOutExpo,
} }
+6 -1
View File
@@ -62,7 +62,12 @@ animations {
} }
``` ```
Currently, niri only supports two curves: `ease-out-cubic` and `ease-out-expo`. Currently, niri only supports three curves:
- `ease-out-quad` <sup>Since: 0.1.5</sup>
- `ease-out-cubic`
- `ease-out-expo`
You can get a feel for them on pages like [easings.net](https://easings.net/). You can get a feel for them on pages like [easings.net](https://easings.net/).
#### Spring #### Spring