Animate a Digital Clock
Beautiful animated digital clock with morphing 7-segment digits, particle effects, multiple color themes, and 12/24-hour format. Runs in real time.
About
A digital clock that merely displays numbers is a solved problem. This tool renders time as a fully animated 7-segment display on an HTML Canvas, where each digit morphs smoothly between states using cubic-eased interpolation. When a digit changes, a particle burst reinforces the transition visually. The colon separator pulses on a sinusoidal opacity curve synced to real seconds. All rendering runs inside a single requestAnimationFrame loop at native refresh rate, with zero DOM reflows. The glow effect uses shadowBlur compositing, not CSS filters, so it stays GPU-friendly. Note: time accuracy depends on the host device clock. Drift from UTC is not corrected here.
Five color presets map to curated pastel palettes. The 12-hour format appends an AM/PM indicator with its own fade animation. Reduced-motion preference disables particles and morphing, falling back to instant digit swaps. The canvas scales responsively but maintains a fixed aspect ratio of 4:1 to prevent distortion. All preferences persist across sessions via localStorage.
Formulas
Segment opacity during digit transition uses cubic ease-in-out interpolation over duration D:
Each segment's rendered opacity blends between old state sold and new state snew:
Colon separator opacity follows a sine pulse:
where t = fractional seconds from Date.now(). Particle position updates each frame with gravity g = 0.15px/frame2:
Reference Data
| Segment | Position | Digits Active | Binary Mask |
|---|---|---|---|
| A (top) | Horizontal top | 0, 2, 3, 5, 6, 7, 8, 9 | 1110111 |
| B (top-right) | Vertical upper-right | 0, 1, 2, 3, 4, 7, 8, 9 | 1101101 |
| C (bottom-right) | Vertical lower-right | 0, 1, 3, 4, 5, 6, 7, 8, 9 | 1111101 |
| D (bottom) | Horizontal bottom | 0, 2, 3, 5, 6, 8, 9 | 1011011 |
| E (bottom-left) | Vertical lower-left | 0, 2, 6, 8 | 1010010 |
| F (top-left) | Vertical upper-left | 0, 4, 5, 6, 8, 9 | 1001011 |
| G (middle) | Horizontal center | 2, 3, 4, 5, 6, 8, 9 | 0111110 |
| Color Presets | |||
| Ocean | #7C9EF5 primary, #A8C4F7 glow | ||
| Coral | #F5A07C primary, #F7C4A8 glow | ||
| Mint | #7CF5B8 primary, #A8F7D0 glow | ||
| Lavender | #B87CF5 primary, #D0A8F7 glow | ||
| Rose | #F57CA0 primary, #F7A8C0 glow | ||
| Animation Timing | |||
| Digit morph | 400ms cubic ease-in-out | ||
| Colon pulse | Sinusoidal, period 1s | ||
| Particle lifetime | 600ms | ||
| Particle count | 20 per digit change | ||