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

Polymorphic base for all animation curves. More...

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

Inheritance diagram for PhosphorAnimation::Curve:
[legend]

Public Member Functions

virtual ~Curve ()=default
 
virtual QString typeId () const =0
 Stable identifier for this curve subclass (e.g. "bezier", "spring").
 
virtual qreal evaluate (qreal t) const =0
 Evaluate at normalized time t in [0,1]. May overshoot by design.
 
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 bool overshoots () const
 True if this curve may evaluate outside [0,1] during progression.
 
virtual qreal settleTime () const
 Approximate settle time in seconds.
 
virtual QString toString () const =0
 Serialize to "typeId:params" or bare "x1,y1,x2,y2" for cubic-bezier.
 
virtual std::unique_ptr< Curveclone () const =0
 Deep copy with identical parameters.
 
virtual bool equals (const Curve &other) const
 Same typeId + same parameters.
 

Protected Member Functions

 Curve ()=default
 
 Curve (const Curve &)=default
 
Curveoperator= (const Curve &)=default
 
 Curve (Curve &&)=default
 
Curveoperator= (Curve &&)=default
 

Detailed Description

Polymorphic base for all animation curves.

Uses a polymorphic hierarchy (not std::variant) so third parties can register additional curve types at runtime via CurveRegistry. Immutable after construction through the shared call path (shared_ptr<const Curve>).

Two progression models:

  • Parametric (evaluate): value at normalized t in [0,1]. Fixed-duration.
  • Stateful (step): advances CurveState by dt toward target. Physics integration.

Thread-safe: all const methods callable from any thread. step() mutates only the caller-owned CurveState.

Constructor & Destructor Documentation

◆ ~Curve()

virtual PhosphorAnimation::Curve::~Curve ( )
virtualdefault

◆ Curve() [1/3]

PhosphorAnimation::Curve::Curve ( )
protecteddefault

◆ Curve() [2/3]

PhosphorAnimation::Curve::Curve ( const Curve )
protecteddefault

◆ Curve() [3/3]

PhosphorAnimation::Curve::Curve ( Curve &&  )
protecteddefault

Member Function Documentation

◆ clone()

virtual std::unique_ptr< Curve > PhosphorAnimation::Curve::clone ( ) const
pure virtual

Deep copy with identical parameters.

Implemented in PhosphorAnimation::Easing, and PhosphorAnimation::Spring.

◆ equals()

virtual bool PhosphorAnimation::Curve::equals ( const Curve other) const
virtual

Same typeId + same parameters.

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

Reimplemented in PhosphorAnimation::Easing, and PhosphorAnimation::Spring.

◆ evaluate()

virtual qreal PhosphorAnimation::Curve::evaluate ( qreal  t) const
pure virtual

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

Implemented in PhosphorAnimation::Spring, and PhosphorAnimation::Easing.

◆ isStateful()

virtual bool PhosphorAnimation::Curve::isStateful ( ) const
inlinevirtual

True if this curve requires persistent CurveState across frames.

Reimplemented in PhosphorAnimation::Spring.

◆ operator=() [1/2]

Curve & PhosphorAnimation::Curve::operator= ( const Curve )
protecteddefault

◆ operator=() [2/2]

Curve & PhosphorAnimation::Curve::operator= ( Curve &&  )
protecteddefault

◆ overshoots()

virtual bool PhosphorAnimation::Curve::overshoots ( ) const
inlinevirtual

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

Reimplemented in PhosphorAnimation::Easing, and PhosphorAnimation::Spring.

◆ settleTime()

virtual qreal PhosphorAnimation::Curve::settleTime ( ) const
inlinevirtual

Approximate settle time in seconds.

Parametric: 1.0 (the [0,1] domain). Spring: analytical 99% settle time. Never infinity.

Reimplemented in PhosphorAnimation::Spring.

◆ step()

virtual void PhosphorAnimation::Curve::step ( qreal  dt,
CurveState state,
qreal  target 
) const
virtual

Advance state by dt real seconds toward target.

dt <= 0 is a no-op. Default impl maps to parametric evaluation using state.startValue/time/duration. For retarget with stateless curves: set startValue = value, time = 0 before changing target.

Reimplemented in PhosphorAnimation::Spring.

◆ toString()

virtual QString PhosphorAnimation::Curve::toString ( ) const
pure virtual

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

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

Implemented in PhosphorAnimation::Easing, and PhosphorAnimation::Spring.

◆ typeId()

virtual QString PhosphorAnimation::Curve::typeId ( ) const
pure virtual

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

Implemented in PhosphorAnimation::Easing, and PhosphorAnimation::Spring.


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