Animate an Hourglass
Interactive animated hourglass timer with realistic sand physics, customizable duration, sand colors, and smooth flip animation. Pure Canvas 2D.
About
An hourglass measures time through granular flow - sand grains falling under gravity through a constricted neck between two glass bulbs. The flow rate depends on the neck diameter, grain size, and bulk density of the sand, approximated by the Beverloo equation where discharge rate W scales with do5/2 (orifice diameter raised to the 2.5 power). Real hourglasses drift 1 - 3% per cycle due to humidity and grain fracture. This tool renders a physically-plausible particle simulation on Canvas at 60fps, conserving total sand volume between bulbs. Duration accuracy is governed by requestAnimationFrame timestamps, not frame counting, so it remains precise regardless of display refresh rate.
Limitations: the simulation uses simplified 2D collision geometry rather than DEM (Discrete Element Method) granular dynamics. Particle-to-particle friction and rotational inertia are omitted. The visual result is convincing but not a calibrated physical model. Pro tip: for presentation timers, pick a duration slightly shorter than your slot - audiences notice overruns more than early finishes.
Formulas
The Beverloo equation models granular discharge rate through an orifice:
Where W = mass flow rate kg/s, C ≈ 0.58 (empirical constant), ρb = bulk density kg/m3, g = gravitational acceleration 9.81 m/s2, do = orifice diameter m, dp = particle diameter m, and k ≈ 1.4 (shape factor).
In this simulation, the remaining sand fraction at time t is computed as:
Where T = total configured duration s. The particle emitter rate is proportional to NT particles per second, where N = total grain count. Each particle undergoes vertical acceleration ay = g (scaled to pixel space) with position updated via Euler integration: yn+1 = yn + vy ⋅ Δt + 0.5 ⋅ g ⋅ Δt2.
Reference Data
| Historical Hourglass | Era | Duration | Neck Diameter | Sand Type | Use Case |
|---|---|---|---|---|---|
| Marine Watch Glass | 14th century | 30 min | 2 - 3 mm | Marble dust | Naval watch shifts |
| Church Sermon Timer | 15th century | 60 min | 3 mm | Crushed eggshell | Limiting sermon length |
| Cooking Glass | 18th century | 3 min | 1.5 mm | Fine silica | Egg boiling |
| Pharmacist's Glass | 17th century | 1 min | 1 mm | Iron filings | Timed preparations |
| Parliament Timer | 16th century | 15 min | 2 mm | Black marble dust | Debate time limits |
| Navigation Ampolleta | 1500s | 30 min | 2.5 mm | Ground feldspar | Dead reckoning at sea |
| Industrial Process Timer | 19th century | 5 min | 2 mm | Tin oxide powder | Factory process timing |
| Board Game Timer | 20th century | 1 - 3 min | 1.5 mm | Dyed silica | Chess & parlor games |
| Sauna Timer | Modern | 15 min | 3 mm | Colored glass beads | Sauna session length |
| Toothbrush Timer | Modern | 2 min | 1 mm | Plastic micro-beads | Dental hygiene |
| Tea Steeping Glass | Modern | 3 - 5 min | 1.5 mm | Stainless steel shot | Brewing precision |
| Meditation Timer | Modern | 10 - 30 min | 2 mm | Colored sand | Mindfulness sessions |