Skip to content

Quantize coordinates on save (#20)#41

Open
MisterGC wants to merge 2 commits into
release/0.4.0from
20-quantize-coordinates-on-save-to-keep-gra
Open

Quantize coordinates on save (#20)#41
MisterGC wants to merge 2 commits into
release/0.4.0from
20-quantize-coordinates-on-save-to-keep-gra

Conversation

@MisterGC
Copy link
Copy Markdown
Owner

Fixes #20 — auto-save now writes integer-pixel coordinates so a 1-px drag produces a 1-line diff instead of ~14 digits of float noise.

  • grafli/format.py: single _q() helper rounds box / note / image x/y/w/h and arrow @dx,dy label offsets on serialize; replaces the per-field "emit int when it happens to equal int(v)" checks. Drops arrow offset entirely when both components round to 0.
  • Tests: updated the two existing tests that asserted fractional preservation; added six new tests (box/note/image/arrow quantization, the (0,0) offset omission, no-float-noise on the showcase round-trip, and a parse→serialize→parse→serialize byte-stable double round-trip). 332 / 332 passing.
  • examples/*.grafli: re-saved through the new serializer to remove the float noise already present in the repo (4 files; ~83 lines re-saved per file). Legitimate decimals inside labels (v0.1.0, 2.0) are untouched.

Test plan

  • pytest -q — 332 passed
  • Drag any box in examples/showcase.grafli and save; git diff should show a 1-line integer-coord change with no float noise
  • Open / save each example file untouched — round-trip leaves it byte-identical

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