Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
PhosphorAnimation::Easing Class Referencefinal

Parametric easing curve: cubic bezier, elastic, or bounce. More...

#include <phosphor-animation/include/PhosphorAnimation/Easing.h>

Inheritance diagram for PhosphorAnimation::Easing:
[legend]

Public Types

enum class  Type {
  CubicBezier , ElasticIn , ElasticOut , ElasticInOut ,
  BounceIn , BounceOut , BounceInOut
}
 

Public Member Functions

 Easing ()=default
 
 Easing (const Easing &)=default
 
Easingoperator= (const Easing &)=default
 
 Easing (Easing &&)=default
 
Easingoperator= (Easing &&)=default
 
QString typeId () const override
 Stable identifier for this curve subclass (e.g. "bezier", "spring").
 
qreal evaluate (qreal x) const override
 Evaluate at normalized time t in [0,1]. May overshoot by design.
 
QString toString () const override
 Serialize to "typeId:params" or bare "x1,y1,x2,y2" for cubic-bezier.
 
std::unique_ptr< Curveclone () const override
 Deep copy with identical parameters.
 
bool overshoots () const override
 True if this curve may evaluate outside [0,1] during progression.
 
bool equals (const Curve &other) const override
 Same typeId + same parameters.
 
bool operator== (const Easing &other) const
 
bool operator!= (const Easing &other) const
 
- Public Member Functions inherited from PhosphorAnimation::Curve
virtual ~Curve ()=default
 
virtual void step (qreal dt, CurveState &state, qreal target) const
 Advance state by dt real seconds toward target.
 
virtual bool isStateful () const
 True if this curve requires persistent CurveState across frames.
 
virtual qreal settleTime () const
 Approximate settle time in seconds.
 

Static Public Member Functions

static Easing fromString (const QString &str)
 Parse from config string. Returns default OutCubic on failure.
 

Public Attributes

Type type = Type::CubicBezier
 
qreal x1 = 0.33
 Bezier control points (P1, P2). x clamped [0,1]; y clamped [-1,2].
 
qreal y1 = 1.0
 
qreal x2 = 0.68
 
qreal y2 = 1.0
 
qreal amplitude = 1.0
 Elastic: oscillation intensity. Bounce: height scale. [0.5, 3.0].
 
qreal period = 0.3
 Elastic oscillation period. [0.1, 1.0].
 
int bounces = 3
 Bounce count. [1, 8].
 

Additional Inherited Members

- Protected Member Functions inherited from PhosphorAnimation::Curve
 Curve ()=default
 
 Curve (const Curve &)=default
 
Curveoperator= (const Curve &)=default
 
 Curve (Curve &&)=default
 
Curveoperator= (Curve &&)=default
 

Detailed Description

Parametric easing curve: cubic bezier, elastic, or bounce.

All stateless. Default construction yields OutCubic bezier (0.33, 1.00, 0.68, 1.00). Value type with public fields — can be stack-allocated or stored inline.

Member Enumeration Documentation

◆ Type

Enumerator
CubicBezier 
ElasticIn 
ElasticOut 
ElasticInOut 
BounceIn 
BounceOut 
BounceInOut 

Constructor & Destructor Documentation

◆ Easing() [1/3]

PhosphorAnimation::Easing::Easing ( )
default

◆ Easing() [2/3]

PhosphorAnimation::Easing::Easing ( const Easing )
default

◆ Easing() [3/3]

PhosphorAnimation::Easing::Easing ( Easing &&  )
default

Member Function Documentation

◆ clone()

std::unique_ptr< Curve > PhosphorAnimation::Easing::clone ( ) const
overridevirtual

Deep copy with identical parameters.

Implements PhosphorAnimation::Curve.

◆ equals()

bool PhosphorAnimation::Easing::equals ( const Curve other) const
overridevirtual

Same typeId + same parameters.

Default compares toString() (2-decimal rounded); subclasses with precise floats should override.

Reimplemented from PhosphorAnimation::Curve.

◆ evaluate()

qreal PhosphorAnimation::Easing::evaluate ( qreal  t) const
overridevirtual

Evaluate at normalized time t in [0,1]. May overshoot by design.

Implements PhosphorAnimation::Curve.

◆ fromString()

static Easing PhosphorAnimation::Easing::fromString ( const QString &  str)
static

Parse from config string. Returns default OutCubic on failure.

◆ operator!=()

bool PhosphorAnimation::Easing::operator!= ( const Easing other) const
inline

◆ operator=() [1/2]

Easing & PhosphorAnimation::Easing::operator= ( const Easing )
default

◆ operator=() [2/2]

Easing & PhosphorAnimation::Easing::operator= ( Easing &&  )
default

◆ operator==()

bool PhosphorAnimation::Easing::operator== ( const Easing other) const

◆ overshoots()

bool PhosphorAnimation::Easing::overshoots ( ) const
overridevirtual

True if this curve may evaluate outside [0,1] during progression.

Reimplemented from PhosphorAnimation::Curve.

◆ toString()

QString PhosphorAnimation::Easing::toString ( ) const
overridevirtual

Serialize to "typeId:params" or bare "x1,y1,x2,y2" for cubic-bezier.

2-decimal float precision — round-trip is lossy.

Implements PhosphorAnimation::Curve.

◆ typeId()

QString PhosphorAnimation::Easing::typeId ( ) const
overridevirtual

Stable identifier for this curve subclass (e.g. "bezier", "spring").

Implements PhosphorAnimation::Curve.

Member Data Documentation

◆ amplitude

qreal PhosphorAnimation::Easing::amplitude = 1.0

Elastic: oscillation intensity. Bounce: height scale. [0.5, 3.0].

◆ bounces

int PhosphorAnimation::Easing::bounces = 3

Bounce count. [1, 8].

◆ period

qreal PhosphorAnimation::Easing::period = 0.3

Elastic oscillation period. [0.1, 1.0].

◆ type

Type PhosphorAnimation::Easing::type = Type::CubicBezier

◆ x1

qreal PhosphorAnimation::Easing::x1 = 0.33

Bezier control points (P1, P2). x clamped [0,1]; y clamped [-1,2].

◆ x2

qreal PhosphorAnimation::Easing::x2 = 0.68

◆ y1

qreal PhosphorAnimation::Easing::y1 = 1.0

◆ y2

qreal PhosphorAnimation::Easing::y2 = 1.0

The documentation for this class was generated from the following file: