Add linear animation curve

This commit is contained in:
Ivan Molodetskikh 2024-05-12 09:50:16 +04:00
parent d2ed42a157
commit 29c7552852
3 changed files with 6 additions and 1 deletions

View File

@ -657,6 +657,7 @@ pub struct EasingParams {
#[derive(knuffel::DecodeScalar, Debug, Clone, Copy, PartialEq)]
pub enum AnimationCurve {
Linear,
EaseOutQuad,
EaseOutCubic,
EaseOutExpo,

View File

@ -41,6 +41,7 @@ enum Kind {
#[derive(Debug, Clone, Copy)]
pub enum Curve {
Linear,
EaseOutQuad,
EaseOutCubic,
EaseOutExpo,
@ -358,6 +359,7 @@ impl Animation {
impl Curve {
pub fn y(self, x: f64) -> f64 {
match self {
Curve::Linear => x,
Curve::EaseOutQuad => EaseOutQuad.y(x),
Curve::EaseOutCubic => EaseOutCubic.y(x),
Curve::EaseOutExpo => 1. - 2f64.powf(-10. * x),
@ -368,6 +370,7 @@ impl Curve {
impl From<niri_config::AnimationCurve> for Curve {
fn from(value: niri_config::AnimationCurve) -> Self {
match value {
niri_config::AnimationCurve::Linear => Curve::Linear,
niri_config::AnimationCurve::EaseOutQuad => Curve::EaseOutQuad,
niri_config::AnimationCurve::EaseOutCubic => Curve::EaseOutCubic,
niri_config::AnimationCurve::EaseOutExpo => Curve::EaseOutExpo,

View File

@ -71,11 +71,12 @@ animations {
}
```
Currently, niri only supports three curves:
Currently, niri only supports four curves:
- `ease-out-quad` <sup>Since: 0.1.5</sup>
- `ease-out-cubic`
- `ease-out-expo`
- `linear` <sup>Since: 0.1.6</sup>
You can get a feel for them on pages like [easings.net](https://easings.net/).