Add linear animation curve
Browse files at this commit29c7552852874a08f9e70ed52ddfb6be8f55bc69Parent: d2ed42a3 changed files +6 -1
niri-config/src/lib.rsmodified+1 -0
| @@ -657,6 +657,7 @@ pub struct EasingParams { | ||
| 657 | 657 | |
| 658 | 658 | #[derive(knuffel::DecodeScalar, Debug, Clone, Copy, PartialEq)] |
| 659 | 659 | pub enum AnimationCurve { |
| 660 | + Linear, | |
| 660 | 661 | EaseOutQuad, |
| 661 | 662 | EaseOutCubic, |
| 662 | 663 | EaseOutExpo, |
src/animation/mod.rsmodified+3 -0
| @@ -41,6 +41,7 @@ enum Kind { | ||
| 41 | 41 | |
| 42 | 42 | #[derive(Debug, Clone, Copy)] |
| 43 | 43 | pub enum Curve { |
| 44 | + Linear, | |
| 44 | 45 | EaseOutQuad, |
| 45 | 46 | EaseOutCubic, |
| 46 | 47 | EaseOutExpo, |
| @@ -358,6 +359,7 @@ impl Animation { | ||
| 358 | 359 | impl Curve { |
| 359 | 360 | pub fn y(self, x: f64) -> f64 { |
| 360 | 361 | match self { |
| 362 | + Curve::Linear => x, | |
| 361 | 363 | Curve::EaseOutQuad => EaseOutQuad.y(x), |
| 362 | 364 | Curve::EaseOutCubic => EaseOutCubic.y(x), |
| 363 | 365 | Curve::EaseOutExpo => 1. - 2f64.powf(-10. * x), |
| @@ -368,6 +370,7 @@ impl Curve { | ||
| 368 | 370 | impl From<niri_config::AnimationCurve> for Curve { |
| 369 | 371 | fn from(value: niri_config::AnimationCurve) -> Self { |
| 370 | 372 | match value { |
| 373 | + niri_config::AnimationCurve::Linear => Curve::Linear, | |
| 371 | 374 | niri_config::AnimationCurve::EaseOutQuad => Curve::EaseOutQuad, |
| 372 | 375 | niri_config::AnimationCurve::EaseOutCubic => Curve::EaseOutCubic, |
| 373 | 376 | niri_config::AnimationCurve::EaseOutExpo => Curve::EaseOutExpo, |
wiki/Configuration:-Animations.mdmodified+2 -1
| @@ -71,11 +71,12 @@ animations { | ||
| 71 | 71 | } |
| 72 | 72 | ``` |
| 73 | 73 | |
| 74 | -Currently, niri only supports three curves: | |
| 74 | +Currently, niri only supports four curves: | |
| 75 | 75 | |
| 76 | 76 | - `ease-out-quad` <sup>Since: 0.1.5</sup> |
| 77 | 77 | - `ease-out-cubic` |
| 78 | 78 | - `ease-out-expo` |
| 79 | +- `linear` <sup>Since: 0.1.6</sup> | |
| 79 | 80 | |
| 80 | 81 | You can get a feel for them on pages like [easings.net](https://easings.net/). |
| 81 | 82 |