Skip to content

Pin and document that drawText ignores an alpha component in its color - #75

Merged
dmccoystephenson merged 1 commit into
mainfrom
test/pin-draw-text-color-alpha
Nov 16, 2026
Merged

dmccoystephenson merged 1 commit into
mainfrom
test/pin-draw-text-color-alpha

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

Stage B (unit-test expansion) combined with the matching Stage A documentation fix, for the text-color path.

  • drawRectangle's handling of an (r, g, b, a) color is already documented and pinned (test: pin that a color's alpha is not blended by drawRectangle #70), but drawText's color and drawButton's colorText were not covered by either.
  • It was verified on pygame 2.1.2 that the alpha component is ignored altogether for text: even a = 0 paints fully opaque glyph stems, on the display and on a pygame.SRCALPHA surface alike. Only the antialiased edges blend.
  • test_draw_text_ignores_the_alpha_of_its_color (parametrized over a = 0 and a = 128) pins this. The test can tell the two behaviours apart: if alpha were respected, a = 0 would paint nothing and a = 128 would blend, so the exact RGB color would never appear in either case.
  • The README alpha paragraph and the drawText / drawButton docstrings now describe the behaviour.

No production behaviour is changed and no public signature is touched, so the consumer-impact gate does not apply.

Test plan

  • python3 -m py_compile src/main/python/preponderous/graphik/graphik.py
  • python3 -m pytest: 157 passed (155 before, plus 2 new parametrized cases)
  • CI Test workflow green across 3.9–3.13 (this also checks the claim against the newer pygame wheels CI installs)

Skipped issues

All open issues were deferred, because each one needs a maintainer decision or touches a path excluded from autonomous change:

No tracking issue: the gap was found during a documentation and test sweep.

This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).

🤖 Generated with Claude Code


drafted by Claude on behalf of Daniel Stephenson

drawRectangle's alpha handling was already documented and pinned, but
drawText's color and drawButton's colorText were not: the alpha is
dropped entirely, so even a = 0 paints opaque text on the display and on
a per-pixel alpha surface.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dmccoystephenson

Copy link
Copy Markdown
Member Author

Self-review rubric (scored against the diff and command output):

  • Scope: PASS. Three files changed: one test, the README alpha paragraph, and two docstring Args entries, all for the same behaviour.
  • Tests-new: PASS (not applicable). No new public method was added. A characterization test was added for existing behaviour.
  • Tests-fix: not applicable. No production code was changed, so there is no fix to revert. The test's ability to tell the behaviours apart was checked by reasoning: respected alpha would paint nothing at a = 0 and blend at a = 128, so the exact (200, 0, 0) / (200, 0, 0, 255) pixels asserted could not appear.
  • Sibling structure: PASS. The test sits beside test_draw_text_renders_in_the_requested_color and follows the _make_graphik / _rgb pattern and the parametrized-alpha style of test_draw_rectangle_paints_a_translucent_color_opaquely_on_the_display.
  • Sibling renames: not applicable. Nothing was renamed.
  • Docs: PASS. The README, the drawText color docstring and the drawButton colorText docstring all describe the behaviour. No version strings were touched.
  • Issue resolution: not applicable. No Closes reference; this gap was found during a sweep.
  • Manual validation: PASS. Locally, py_compile passed and pytest reported 157 passed on pygame 2.1.2. CI Test passed on Python 3.9–3.13, which installs pygame 2.6.1, so the claim holds on both pygame versions.
  • camelCase: not applicable. No new methods.
  • Backward-compat: PASS. No signature or behaviour change.
  • Headless: PASS. The test uses _make_graphik under the conftest's dummy SDL drivers.
  • Version sync: not applicable.
  • No new deps: PASS. No imports were added.

Judgment-call notes:

  • src/main/python/preponderous/graphik/graphik.py:222 documents that drawButton's colorText ignores alpha, but there is no dedicated test for it. The claim follows from drawButton passing colorText straight to drawText (line 254), which the new test covers, so a separate test was judged unnecessary.
  • The direct python3 -c import smoke command could not be run in this sandbox. The same import is covered by test_canonical_import_exposes_graphik_class and by CI's Import smoke test step, which passed.

None of the changed paths is on the do-not-auto-merge list (.github/workflows/*, pom.xml, version.txt, LICENSE, or a file with more than 50 lines deleted).

This review was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

@dmccoystephenson
dmccoystephenson merged commit 5281e4b into main Nov 16, 2026
5 checks passed
@dmccoystephenson
dmccoystephenson deleted the test/pin-draw-text-color-alpha branch November 16, 2026 05:02
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.

1 participant