fix(7-segment-clock): draw the digits, which had gone fully blank - #364
Merged
Conversation
The panel showed nothing. Every asset is a 1-bit bitmap carrying a tRNS chunk,
and both loaders open them with .convert("RGBA") -- which returns alpha 0 for
the WHITE (lit) pixels and alpha 255 for the black ones, exactly inverted.
_colorize then asked for `a > 0 and (r or g or b)`: "visible and not black".
That is false for every pixel in the file. Lit pixels fail the first half, unlit
pixels fail the second. Each tile came back fully transparent, so the clock drew
nothing.
Lit-ness now comes from brightness, which the inverted alpha cannot reach. The
alpha check is not merely relaxed but removed, and the docstring says why: by
the time _colorize runs the alpha is already inverted, so "restoring" an alpha
test blanks the display again. That is the trap this fix exists to close.
Verified against the goldens captured before the regression: unfixed, all eight
harness renders drift (up to 7062px, max delta 255, i.e. black where the clock
should be); fixed, all eight match byte-for-byte. So this restores exactly what
the clock used to draw rather than just making it draw something.
test_render_polarity.py now passes, and its three counts match an independent
audit of the assets: '8' lights 218 pixels, '1' lights 72, the separator 12.
Contributor
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | -6 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
This was referenced Sep 2, 2026
This was referenced Sep 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
test_render_polarity.pyhas been failing onmain, and it was right: the clock renders nothing at all on the panel.The bug
Every digit and separator asset is a 1-bit bitmap carrying a
tRNSchunk. Both loaders open them with.convert("RGBA"), which returns alpha 0 for the white (lit) pixels and alpha 255 for the black (unlit) ones — exactly inverted._colorizethen asked fora > 0 and (r or g or b)— "visible and not black". That is false for every pixel in the file:a > 0r or g or bEvery tile came back fully transparent, so the panel stayed dark.
The fix
Lit-ness now comes from brightness, which the inverted alpha cannot reach.
The alpha check is removed, not relaxed, and the docstring says why: by the time
_colorizeruns, the alpha is already inverted, so "restoring" an alpha test blanks the display again. I hit that exact trap while writing this — an intermediate version kept a defensivealpha > 0veto and reproduced the blank clock.Verification
Against the goldens captured before the regression:
mainSo this restores exactly what the clock used to draw, rather than merely making it draw something.
test_render_polarity.pypasses, and its three counts independently match an audit of the asset files:8lights 218 pixels,1lights 72, the separator 12 — the right ordering for correct polarity.