feat(render): independent major and minor grid classes tied to the tick set

This commit is contained in:
Martino Ferrari committed 2026-09-28 12:42:22 +02:00
1 parent 69495a3799
commit eaae07d8e0
7 files changed
+635 -16

No files matched your search

+11 -1
View File
@@ -12,16 +12,26 @@ namespace plot {
/// baking screen coordinates in here would break that uniform-only contract.
struct GridLine {
f64 x0 = 0.0, y0 = 0.0, x1 = 0.0, y1 = 0.0;
/// The class of the tick this segment came from: a major (labelled) tick, or one
/// of the minor subdivisions between them. The renderer picks the class' colour
/// and width from it, so the tick set is the one source for grid positions and
/// `Style` the one place that decides how a class looks and whether it is drawn.
bool major = true;
};
/// Tick-aligned grid geometry: one segment per tick, spanning the perpendicular
/// axis' full range.
class Grid {
///
/// Every tick within the perpendicular range contributes a segment, whatever its
/// class, tagged by it. Whether a class is *drawn* is style rather than geometry:
/// the renderer checks `Style::grid_major_visible` / `grid_minor_visible` per class
/// before it stages a segment, which is the only switch for that behaviour (spec
/// §11). A `Grid` therefore carries both classes' geometry whatever the style says,
/// and a caller that draws it itself applies the same two switches.
public:
bool vertical = true; ///< emit lines at x ticks
bool horizontal = true; ///< emit lines at y ticks
bool show_minor = true; ///< keep minor-tick lines
/// Rebuilds the segments from each axis' ticks and range. Ticks outside the
/// perpendicular range (or non-finite) are skipped, so a stale tick list can