Skip to content

fix(line): clamp thickness <= length to avoid ^GB promotion#71

Merged
u8array merged 2 commits into
mainfrom
fix/line-thickness-promotion
May 17, 2026
Merged

fix(line): clamp thickness <= length to avoid ^GB promotion#71
u8array merged 2 commits into
mainfrom
fix/line-thickness-promotion

Conversation

@u8array
Copy link
Copy Markdown
Owner

@u8array u8array commented May 17, 2026

No description provided.

Zebra firmware promotes ^GB w,h,t with t > min(w,h) to max(w,t) x max(h,t),
so a vertical line emitted as ^GB t,length,t prints as a t x t square once
thickness exceeds length rather than the declared length x t band. Enforce
the t <= length invariant at every edit path:

- Thickness side-handle drag caps at p.length
- Property panel thickness gets max=p.length, length gets min=p.thickness
  (NumberInput already clamps typed values, so the cap is authoritative)
- Start/end handle drag commits cap thickness to the new length so
  shrinking a line below its current thickness pulls thickness down
  rather than violating the invariant

Existing stored lines with t > length keep their data and continue to
print the promoted square; touching any handle or input snaps them back
into a valid state. An explicit import-time warning for this case will
follow in a separate change.
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request ensures that a line's thickness does not exceed its length to prevent ZPL rendering issues where the printer would otherwise output a square instead of a line. Changes include clamping thickness during canvas interactions and adding constraints to the property panel inputs. Feedback suggests improving the live preview's visual consistency during drags by applying clamping to the rendering logic and refining the property panel's UX by automatically adjusting thickness instead of using a restrictive minimum length constraint.

Comment thread src/components/Canvas/LineObject.tsx
Comment thread src/registry/line.tsx Outdated
Two follow-ups from Gemini review on PR #71:

- LineObject visual stroke is now capped at the live endpoint distance
  so an endpoint-shrink no longer briefly renders a band wider than the
  line is long. The data model invariant (t <= length) already holds in
  steady state, so the cap is a no-op outside of an active drag.
- Length input drops the min=p.thickness floor; instead the onChange
  shrinks thickness alongside length, matching the endpoint-handle
  commit. Thickness max=p.length stays — the inverse direction (typing
  thickness larger than length would auto-grow length) isn't a natural
  user intent.
@u8array u8array merged commit f94f20f into main May 17, 2026
2 checks passed
@u8array u8array deleted the fix/line-thickness-promotion branch May 17, 2026 20:32
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