Control panel
All controls are located in a semi-transparent panel in the top-right corner of the screen:The control panel uses responsive spacing and sizing to adapt to mobile and desktop screens. On smaller screens, controls are more compact.
Speed control
Adjust the animation speed from 0.1x to 3.0x using a range slider.Implementation
UI component
How speed affects animation
How speed affects animation
The speed value directly multiplies the drop position increment:
- Speed 0.1x: Drops move 0.1 pixels per frame
- Speed 1.0x: Drops move 1 pixel per frame (default)
- Speed 3.0x: Drops move 3 pixels per frame
Speed ranges
- Slow (10-50%)
- Normal (50-150%)
- Fast (150-300%)
Perfect for:
- Background ambiance
- Meditative viewing
- Low-distraction environments
- Reading individual characters
Color picker
Select any custom color for the falling characters when not in RGB mode.Implementation
UI component
The color picker is automatically disabled when RGB mode is active, preventing conflicts between static and dynamic color modes.
Popular color choices
- #00FF00 - Classic Matrix green (default)
- #FF0000 - Red for a danger/alert theme
- #00FFFF - Cyan for a cyberpunk aesthetic
- #FFFFFF - White for high contrast
- #FFD700 - Gold for a premium look
RGB mode
Enable dynamic rainbow colors that cycle through the spectrum.Implementation
Color calculation
RGB color algorithm explained
RGB color algorithm explained
The RGB effect uses HSL (Hue, Saturation, Lightness) color space:
- Time offset: Increments by 0.5 each frame, creating global color shift
- Drop position: Each drop’s Y position influences its hue
- Hue calculation:
(dropY * 2 + timeOffset) % 360 - Result: Vertical rainbow gradient that animates over time
UI component
Direction toggle
Switch between falling down and rising up animations.Implementation
Drop initialization
When direction changes, all drops are reinitialized with appropriate starting positions to prevent visual glitches. Falling drops start above the viewport, rising drops start below.
Movement logic
The
Math.random() > 0.975 check creates a 2.5% chance per frame for a drop to reset. This prevents all drops from resetting simultaneously and maintains visual variety.UI component
State management with refs
All controls use a combination of React state and refs for optimal performance:Why use both state and refs?
Why use both state and refs?
This pattern provides two benefits:
- State triggers UI updates: Changing
sliderValuere-renders the component to show the new value in the UI - Refs avoid stale closures: The animation loop accesses
speedRef.currentwhich always contains the latest value, even though the loop function isn’t recreated
Responsive design
All controls adapt to screen size:- Mobile (<640px)
- Tablet (640-768px)
- Desktop (>768px)
- Control width: 128px (w-32)
- Text size: 12px (text-xs)
- Padding: 8px (p-2)
- Top/right offset: 8px (top-2 right-2)