psychic-ui 0.0.0
Loading...
Searching...
No Matches
psychic_ui::Ease Struct Reference

#include <Timing.hpp>

Public Member Functions

float at (float progress) const
float slope (float progress) const
Approach approach (float offset0, float seconds, float duration) const
constexpr bool operator== (const Ease &) const =default

Public Attributes

float x1 {0.0f}
float y1 {0.0f}
float x2 {1.0f}
float y2 {1.0f}

Static Public Attributes

static const Ease Linear {.x1 = 0.0f, .y1 = 0.0f, .x2 = 1.0f, .y2 = 1.0f}
static const Ease Standard {.x1 = 0.25f, .y1 = 0.1f, .x2 = 0.25f, .y2 = 1.0f}
static const Ease In {.x1 = 0.42f, .y1 = 0.0f, .x2 = 1.0f, .y2 = 1.0f}
static const Ease Out {.x1 = 0.0f, .y1 = 0.0f, .x2 = 0.58f, .y2 = 1.0f}
static const Ease InOut {.x1 = 0.42f, .y1 = 0.0f, .x2 = 0.58f, .y2 = 1.0f}

Detailed Description

An easing curve: a cubic Bézier from (0, 0) to (1, 1) through two control points, like CSS's cubic-bezier(). at(x) is how far along its way a value is (y) at a share of the duration (x, 0 to 1). y may leave 0-1 (an overshoot); the control points' x may not.

Ease::Out                                            // A named curve, CSS's `ease-out`
Ease{.x1 = 0.16f, .y1 = 1.0f, .x2 = 0.3f, .y2 = 1.0f}  // Any other, as cubic-bezier(0.16, 1, 0.3, 1)

Member Function Documentation

◆ approach()

Approach psychic_ui::Ease::approach ( float offset0,
float seconds,
float duration ) const
nodiscard

Along this curve for duration seconds from an offset of offset0 at rest, where it is seconds later: offset0 × (1 − at(seconds / duration)), settled once the duration is over

◆ at()

float psychic_ui::Ease::at ( float progress) const
nodiscard

The eased progress at a share of the duration (clamped to 0-1)

◆ slope()

float psychic_ui::Ease::slope ( float progress) const
nodiscard

How fast the eased progress changes at a share of the duration (dy/dx, clamped to 0-1)


The documentation for this struct was generated from the following files: