Skip to content

Draw the line art of Line Attributes - #240

Merged
gunicsba merged 10 commits into
Open-Agriculture:mainfrom
gunicsba:fix/line-art
Nov 5, 2026
Merged

gunicsba merged 10 commits into
Open-Agriculture:mainfrom
gunicsba:fix/line-art

Conversation

@gunicsba

@gunicsba gunicsba commented Sep 27, 2026 •

Copy link
Copy Markdown
Member

Closes #233.

The line art of a Line Attributes object was not used anywhere, so every dashed and dotted line was drawn solid. ISO 11783-6:2018 (B.14.3, Table B.48, Figures B.14 and B.15) gives it one bit per paintbrush spot, the size of the line width, read from the most significant bit and repeated every 16 spots. 1 bits are drawn in the line colour, and 0 bits are skipped so the background shows.

  • Output Line: each drawn spot is one brush at the point of the brush line (Draw Output Line objects with the square paintbrush of ISO 11783-6 #238) that many brush sizes along the line's longer axis, as in Figure B.15. A spot cut short by the end of the line is the part of the last brush that fits. Rendering the lines of Figures B.14 and B.15 matches them pixel for pixel. The vertical lines of data mask 1009 in the pool from this comment on #233 also match the NX9.
  • Output Rectangle: the pattern runs clockwise around the box from the top left corner, one bit per brush-sized spot along the sides (Draw Output Rectangle borders inside the box when a side is suppressed #239). A suppressed side still takes its share of the pattern. The start at the upper left corner is the one 4.6.21 gives, and this is its continuous line art method; 4.6.21 also allows restarting the pattern.
  • Output Ellipse and Output Polygon, which are still drawn as strokes: the pattern becomes dashes and gaps of one line width per bit.

Solid lines (0xFFFF) take the same code path as before. The helper is the new header-only include/LineArt.hpp.

Dashed line before and after

Before and after, over the whole collection

I rendered all 30 pools of AgIsoObjectPoolCollection with vt-render, with #238 and #239 applied, with and without this commit. 6 of 3,970 images changed: one mask and its screen in each of 627223e9, a4b54f27 and ecd03d36. No solid shape changed, so solid rectangles, ellipses and polygons look as before. The collection has 246 dashed shapes, but most are in containers that start hidden.

The Väderstad planter (a4b54f27) draws a small chart whose ±5 and ±10 gridlines are dotted and whose 0 line is solid. Before, all the gridlines looked alike:

Väderstad chart zoomed

The whole mask, before, diff and after:

Väderstad main screen before, diff, after

Notes

  • The collection images above were made before the two Output Line commits, which shorten the dashes of dashed Output Lines to one line width per bit.

  • With the one brush per spot rule, 26 of 4,170 images change compared with the rule before it, all in c99438bd (samplePool3): dm_1008, the soft key mask and the screens that show it.

  • Difference from the NX9 on sloped lines: the dash lengths and extents match, but the NX9's pattern is one bit earlier than ours. On line 13019 (2727, width 5) its dashes start at 5, 20 and 45 px and ours at 10 and 25 px. Straight lines are not shifted. Figure B.15 b and c start with the first bit of the pattern, so this PR follows the figure. The Solsteer View-T differs from both, and 4.6.21 leaves the exact presentation to the VT.

Sloped dashed lines before, after and on the NX9

  • Formatted with the repository's clang-format settings; built with MSVC as part of vt-render.

🤖 Generated with Claude Code

gunicsba and others added 4 commits September 28, 2026 00:07
Lines were drawn from corner to corner of the object's box, centred on that path, so a line thicker
than 1 px came out slanted and half clipped: a 40x8 line with line width 8 was a parallelogram instead
of a solid bar (Open-Agriculture#231). Lines only 1 px high or wide ignored the line width.

ISO 11783-6 (B.10.1, Figure B.4) draws every point with a square paintbrush of the line width, the
point being the brush's upper left corner. The line now runs from (0, 0) to (width - line width,
height - line width), or mirrored for bottom left to top right, with the brush painted at each point
of a Bresenham line. Where the box is narrower than the brush, the end point stays at 0 and the brush
is clipped to the box, as in the figure's examples. A line width of 0 draws nothing, as for rectangles.

Closes Open-Agriculture#231

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Gunics Balázs <gunicsba@gmail.com>
With any side suppressed, the remaining sides were drawn with drawLine along the box edges. drawLine
centres the stroke on the edge, so half of every side was clipped away: line width 2 showed as 1 px,
and the right and bottom sides, on x = width and y = height, were mostly outside the box (Open-Agriculture#232).

ISO 11783-6 draws shapes with a square paintbrush of the line width that stays inside the object's
box. Each side that is not suppressed is now a strip of the line width along the inside of its edge,
which is also what drawRect did for rectangles without suppressed sides, so those look the same.

Closes Open-Agriculture#232

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Gunics Balázs <gunicsba@gmail.com>
The line art of a Line Attributes object was not used anywhere, so dashed and dotted lines were drawn
solid (Open-Agriculture#233). ISO 11783-6 (B.14.3) gives it one bit per paintbrush spot, the size of the line width,
read from the most significant bit and repeated every 16 spots: 1 bits are drawn in the line colour,
0 bits are skipped.

- Output Line: each point of the brush line is drawn only if the bit of its spot (its step along the
  line divided by the brush size) is set.
- Output Rectangle: the pattern runs clockwise around the box from the top left corner, one bit per
  brush sized spot along the sides; a suppressed side still takes its share of the pattern.
- Output Ellipse and Output Polygon, which are drawn as strokes: the pattern becomes dashes and gaps,
  one line width per bit.

Solid lines (0xFFFF) are drawn as before.

Closes Open-Agriculture#233

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Gunics Balázs <gunicsba@gmail.com>
The brush reaches brush size - 1 steps past its point, so every dash grew into
the gap after it: with a 5 px line, 0x5555 drew 9 px dashes and 1 px gaps.
The brush is now painted only where everything it covers is drawn, so a bit
is exactly one line width along the line, as on the NX9 and Solsteer View-T
in Open-Agriculture#233.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gunicsba and others added 2 commits October 1, 2026 22:29
Instead of skipping the whole brush when it covers a skipped spot, only the
slices of the brush that cover drawn spots are painted. Dashes and gaps stay
one line width long, and a spot cut short by the end of the line is now drawn
for the part that fits, as the NX9 does in Open-Agriculture#233. All six lines of data mask
1009 in that pool now match the NX9 pixel for pixel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Open-Agriculture#238 was squashed into main as it is in this branch, so the branch's
OutputLineComponent.cpp, which builds on it, is kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gunicsba
gunicsba requested a review from sujandumaru November 3, 2026 11:12
Comment thread src/OutputLineComponent.cpp Resolved
Comment thread src/OutputLineComponent.cpp Resolved
A dash painted the brush at every point of the line, keeping the slices
in its spot. On a sloped line the brush after a step reached one row
past the spot, which added a pixel to the dash. ISO 11783-6:2018 Figure
B.15 shows each spot as one brush, at the point that many brush sizes
along the line. A spot cut short by the end of the line is the part of
the last brush that fits, so straight lines draw the same pixels.

Also cite the figures by their 2018 numbers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gunicsba added a commit to gunicsba/AgIsoVirtualTerminal that referenced this pull request Nov 5, 2026
@gunicsba
gunicsba requested a review from sujandumaru November 5, 2026 20:05
The stack and the VT don't use anonymous namespaces, and members are
easier to spot and share with similar objects.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gunicsba
gunicsba merged commit fb94cc9 into Open-Agriculture:main Nov 5, 2026
7 checks passed
@gunicsba
gunicsba deleted the fix/line-art branch November 5, 2026 20:39
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.

Line art (dashed lines) is ignored

2 participants