Repository navigation
test: pin how fractional positions and sizes are drawn and hit-tested - #62
Merged
Merged
Conversation
Floats are truncated toward zero per argument by drawRectangle, drawButton and drawImage; drawText accepts a fractional center but rejects a fractional size. drawButton's hit test uses the unrounded values, so its clickable region can drift from the drawn box by up to a pixel per edge -- characterized here and documented, not changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The class docstring said fractional sizes are accepted, contradicting drawText's int-only font size. Also rename two parametrize ids that described each tuple as wholly above/below half when it mixes both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
|
Self-review rubric (performed inline; no independent reviewer is available, and Copilot could not be added as a reviewer):
Notes:
This review comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener). drafted by Claude on behalf of Daniel Stephenson |
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.
Summary
Stage B (unit-test expansion) cycle. How the draw methods handle fractional (float) positions and sizes had no tests and no documentation. Consumers lay out grids from divisions such as
displayWidth / columns, so float arguments are common.drawRectangle,drawButton,drawImage: each ofxpos,ypos,widthandheightis pinned as truncated toward zero on its own. It is not rounded, and the far edge is not computed from the unroundedxpos + width. A box at10.7with width5.9covers pixels 10..14. A size below one pixel draws nothing.drawText: a fractional center is accepted. A fractionalsizeraisesTypeErrorfrompygame.font.Font, and that is now pinned and stated in the docstring.drawButtonhit test: the hit test compares the mouse against the unrounded floats, so with fractional arguments the clickable region can drift up to a pixel from the painted box on each edge. This contradicts the documented "clickable region is exactly the drawn box". It is characterized by a test and documented as an integer-only guarantee. The production code is unchanged, and the possible fix is filed as drawButton: with fractional arguments the clickable region drifts up to a pixel from the drawn box #61 for a maintainer decision.The
graphik.pyedit is docstring-only. Behavior (including truncation of negative fractions toward zero) was verified on pygame 2.1.2 and 2.6.1 before it was written down.Test plan
python3 -m py_compile src/main/python/preponderous/graphik/graphik.pypython3 -m pytest(headless viaconftest.py): 130 passed, 19 of them new. Run locally on Python 3.8.10 with pygame 2.1.2.Backlog skip reasons
No tracking issue — gap found during triage. #60 was closed this cycle, because the fix landed in #59 and
main's 3.9 job is green again. The remaining open issues are human-gated:.github/workflows/, which is excluded from autonomous change. release: version tags are pushed without the 'v' prefix publish.yml requires, so no release has ever been published #34 also needs a maintainer decision on tag format.preponderous.*namespace convention.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