Skip to content

[Fix] Date/time drop falls at the rain's own rate, on two lines - #119

Merged
ap0ught merged 1 commit into
masterfrom
feat/matrix-clock
Oct 1, 2026
Merged

ap0ught merged 1 commit into
masterfrom
feat/matrix-clock

Conversation

@ap0ught

@ap0ught ap0ught commented Oct 1, 2026

Copy link
Copy Markdown
Owner

Summary

Follow-up to #118, from watching it on the phone: the clock was reading as a separate effect sitting on top of the rain, and the user asked for two things —

  1. fall at the same rate and randomness as the background, so it blends in once it is done
  2. two lines: the date, and the time

Changes

  • js/clock.js
    • rainFallSpeed() mirrors shaders/glsl/rainPass.raindrop.frag.glsl: 100 * raindropLength * fallSpeed * animationSpeed cells per second, each cell glyphVerticalSpacing / numColumns of the screen tall (the grid is square — see js/webgl/rainPass.js), scaled by columnSpeedOffset. The whole fall now takes a few seconds instead of dragging on for fifty.
    • glyphCycleHz() turns the per-frame cycleSpeed into the same ~0.5s glyph re-roll the rain does (1.8 rolls/s at the defaults), and each character also gets the rain's per-column 0.5x–1x speed variation, so the cascade is uneven like the rain rather than a clean diagonal.
    • Characters use the rain's alphabet (SCRAMBLE_CHARSET) for both the heads and the trails.
    • The text is now two lines — THU 01 OCT 2026 over 21:39:00 — with the time line peeling a beat after the date so they don't read as one block.
    • clockPhase() reports elapsed seconds instead of a 0..1 progress, since the motion is now derived from real time and the rain's speed.

The effect is now: 10s hold, ~7s fall, then nothing distinguishable from the rain.

Testing

  • tests/clock-phase.test.mjs — clockLines returns the two lines (with zero padding); rainFallSpeed matches the raindrop maths, scales with viewport/speed settings/column offset and lands in a rain-like range for a phone screen; glyphCycleHz matches the symbol pass; clockPhase boundaries and monotonic elapsed.
  • tests/matrix-clock.spec.js — the fall test now samples three seconds in (the fall is fast), everything else unchanged.
  • npm test — 21 passed, 2 skipped (WebGPU unavailable here)
  • Checked hold and three fall frames at a 420×860 phone viewport
  • npx prettier --check --use-tabs --print-width 160

Notes

  • The gallery spec flaked once during a full parallel npm test run (its red/green assertion is timing sensitive under load) and passed on a rerun and in isolation.

The clock fell over fifty seconds at a rate of its own, which read as a
separate effect sitting on top of the rain. It now borrows the rain's motion:

- js/clock.js: rainFallSpeed() mirrors rainPass.raindrop.frag.glsl
  (100 * raindropLength * fallSpeed * animationSpeed cells per second, each cell
  glyphVerticalSpacing/numColumns of the screen tall), and glyphCycleHz() turns
  the per-frame cycleSpeed into the same ~0.5s glyph re-roll the rain does. Each
  character also gets the rain's per-column 0.5x-1x speed variation, so the
  cascade is uneven like the rain instead of a clean diagonal. The whole effect
  is over in a few seconds and leaves nothing distinguishable from the background.
- Split the text into two lines (date, then time), the time line peeling a beat
  after the date.
- clockPhase() reports elapsed seconds instead of a 0..1 progress, since motion
  is now derived from real time and speed rather than a normalised clock.
Copilot AI balanced review requested due to automatic review settings October 1, 2026 16:37
@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown

🎬 PR Preview Deployed!

Your changes are now available for testing:

Preview URL: https://ap0ught.github.io/matrix/pr-119/

Test Links:

The preview will be updated automatically when you push new commits.


Preview deployed from commit 17b96f3

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 17b96f33ec

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread js/clock.js
return {
phase: "fall",
progress: (secondsIntoMinute - CLOCK_HOLD_SECONDS) / CLOCK_FALL_SECONDS,
elapsed: secondsIntoMinute - CLOCK_HOLD_SECONDS,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve subsecond precision in the fall elapsed time

secondsIntoMinute originates from Date#getSeconds(), so this elapsed value changes only once per second. During every fall, the 0.09-second stagger consequently releases roughly eleven characters at once, while both their positions and glyph rolls remain frozen between second boundaries, rather than moving and re-rolling at the rain's cadence. Derive elapsed time with millisecond precision before passing it to drawFall.

Useful? React with 👍 / 👎.

Comment thread js/clock.js
Comment on lines +78 to +80
export function glyphCycleHz(config) {
const { cycleSpeed = 0.03, animationSpeed = 1 } = config ?? {};
return Math.max(0.5, animationSpeed * cycleSpeed * ASSUMED_FPS);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Derive glyph cadence without the fixed 60 Hz floor

This calculation cannot match the renderer outside the assumed default: the shader advances its glyph age on each animation tick, so a 120 Hz display cycles twice as quickly as this overlay, while animationSpeed=0 freezes the shader but the Math.max(0.5, ...) floor keeps the overlay changing. The cadence should track the renderer's actual updates and be allowed to reach zero instead of imposing a 60 Hz conversion and minimum rate.

Useful? React with 👍 / 👎.

Comment thread js/clock.js
Comment on lines +294 to +296
const y = headerY + age * rainFallSpeed(this.config, height, columnSpeedOffset(i));
if (y - this.trailLength * step > height) {
continue; // Gone; the rain below takes over.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep slow rain presets from resetting the drop mid-screen

For slow supported configurations, the rate-based fall cannot finish before the minute rolls over, at which point clockPhase immediately redraws the next clock at the header and discards the in-flight glyphs. For example, the built-in paradise preset (fallSpeed=0.02, raindropLength=0.4, numColumns=40) moves its slowest columns only 10 px/s on a 1000 px viewport, so after the available 49 seconds their heads are still around mid-screen and their trails are far from clear. Preserve outstanding drops across the minute boundary or otherwise account for rates that require longer than one minute.

Useful? React with 👍 / 👎.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Whole-second animation timing and incorrect renderer-speed calculations prevent the overlay from reliably matching the background rain.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)
What changed in this PR

Refines #118’s date/time overlay so it uses two lines and visually blends into the digital rain while falling.

Changes:

  • Splits date and time into separate lines.
  • Derives fall speed and glyph cycling from renderer configuration.
  • Updates clock tests and documentation.
File Description
js/​clock.js Implements two-line, rain-paced falling animation.
tests/​clock-phase.test.mjs Tests formatting, timing, speed, and glyph cadence.
tests/​matrix-clock.spec.js Updates browser fall-position assertions.
README.md Documents the revised overlay behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread js/clock.js
Comment on lines +68 to +69
const cellsPerSecond = 100 * raindropLength * fallSpeed * animationSpeed * columnSpeedOffset;
return cellsPerSecond * ((glyphVerticalSpacing / numColumns) * viewportHeight);
Comment thread js/clock.js
const y = headerY + eased * (height + fontSize * 2);
const head = scrambledGlyph(i, tick);
const step = fontSize * 1.05;
const y = headerY + age * rainFallSpeed(this.config, height, columnSpeedOffset(i));
@ap0ught
ap0ught merged commit 7c751d5 into master Oct 1, 2026
5 checks passed
@ap0ught
ap0ught deleted the feat/matrix-clock branch October 1, 2026 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants