โ† All libraries

HoneyBounce

๐Ÿ HoneyBounce

Damped spring physics + Newtonian projectile sim

port of harmonica physics animation math no-deps

Pure-math animation engine. Damped harmonic oscillators (Ryan-Juckett) for smooth scroll / overshoot, Newtonian projectile sim for arcs and particle effects. No terminal dependency.

Install

composer require candycore/honey-bounce

Quickstart

use CandyCore\Bounce\{Spring, Projectile, Point, Vector};

$spring = new Spring(
    deltaTime:        Spring::fps(60),
    angularFrequency: 6.0,
    dampingRatio:     1.0,    // critical
);
$pos = 0.0; $vel = 0.0; $target = 100.0;
for ($f = 0; $f < 60; $f++) {
    [$pos, $vel] = $spring->update($pos, $vel, $target);
}

$ball = Projectile::new(
    deltaTime:    Spring::fps(60),
    position:     Point::zero(),
    velocity:     new Vector(5.0, -10.0),
    acceleration: Projectile::gravity(),
);
for ($i = 0; $i < 60; $i++) {
    $ball = $ball->update();
}

What's in the box

SpringdampingRatio < 1 oscillates, = 1 critical (no overshoot, fastest), > 1 over-damped.
ProjectilePosition, velocity, acceleration vectors. Projectile::gravity() + terminalGravity() helpers.
Frame helpersSpring::fps(60) returns 1/60 deltaTime. Pair with a 60Hz loop for smooth animation.
Pure functionsNo state hidden in the engine โ€” caller passes $pos and $vel in, gets the next pair out.
Used everywhereAnimatedProgress, Viewport scroll, ItemList paging โ€” every smooth motion in SugarBits goes through HoneyBounce.
Zero depsNo ReactPHP, no ext-pcntl, nothing. Drop into a job worker if you need physics in a non-TUI.

Source & demos

Try the quickstart โ†’

Demos.

VHS-recorded GIFs of every example shipped with the library. Regenerated automatically on every push that touches the source.

Spring

Spring

Damped harmonic oscillator โ€” settles smoothly to its target.
Projectile

Projectile

Newtonian projectile sim with gravity + bouncing.