69 velocity = releaseVelocity;
79 if (std::abs (velocity) < minimumVelocity)
94 double velocity = 0, damping = 0.92, minimumVelocity = 0.05;
120 targetSnapPosition =
std::floor (position + 0.5);
122 if (releaseVelocity > 1.0 && targetSnapPosition < position) ++targetSnapPosition;
132 return targetSnapPosition;
146 return std::abs (targetSnapPosition - position) < 0.001;
150 double targetSnapPosition = 0.0;
Contains classes for different types of physics behaviours - these classes are used as template param...
constexpr bool approximatelyEqual(Type a, Type b, Tolerance< Type > tolerance=Tolerance< Type >{} .withAbsolute(std::numeric_limits< Type >::min()) .withRelative(std::numeric_limits< Type >::epsilon()))
Returns true if the two floating-point numbers are approximately equal.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
A non-snapping behaviour that allows the content to be freely flicked in either direction,...
bool isStopped(double) const noexcept
Called by the AnimatedPosition class to check whether the object is now stationary.
double getNextPosition(double oldPos, double elapsedSeconds) noexcept
Called by the AnimatedPosition class to get the new position, after the given time has elapsed.
void setFriction(double newFriction) noexcept
Sets the friction that damps the movement of the value.
void releasedWithVelocity(double, double releaseVelocity) noexcept
Called by the AnimatedPosition class.
void setMinimumVelocity(double newMinimumVelocityToUse) noexcept
Sets the minimum velocity of the movement.
A behaviour that gravitates an AnimatedPosition object towards the nearest integer position when rele...
bool isStopped(double position) const noexcept
Called by the AnimatedPosition class to check whether the object is now stationary.
double getNextPosition(double oldPos, double elapsedSeconds) const noexcept
Called by the AnimatedPosition class to get the new position, after the given time has elapsed.
void releasedWithVelocity(double position, double releaseVelocity) noexcept
Called by the AnimatedPosition class.