mirror of
https://github.com/YaLTeR/niri.git
synced 2024-09-11 12:35:58 +03:00
Add linear animation curve
This commit is contained in:
parent
d2ed42a157
commit
29c7552852
@ -657,6 +657,7 @@ pub struct EasingParams {
|
||||
|
||||
#[derive(knuffel::DecodeScalar, Debug, Clone, Copy, PartialEq)]
|
||||
pub enum AnimationCurve {
|
||||
Linear,
|
||||
EaseOutQuad,
|
||||
EaseOutCubic,
|
||||
EaseOutExpo,
|
||||
|
@ -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,
|
||||
|
@ -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/).
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user