style(grid): the minor grid is thinner, dashed and blended into the background
Subdivisions used to be drawn exactly like the labelled lines -- same width, same opacity -- so a plot dense enough to need them read as two competing sets of ticks. The minor class is now three things the style states explicitly: - grid_minor_width 1.0 -> 0.75, a sub-pixel logical width. At 1x that is expressed as reduced coverage through the anti-aliased ramp; on a HiDPI display the line is literally narrower. - grid_minor_dash_on/_off (new, 3/3): dashed by default, off == 0 draws it solid, the same convention as the crosshair's and a trace's dash. The dash is a fragment-shader discard, so no geometry is added -- the vertices are the line either way. - grid_minor carries alpha (0x1C2126 at 50%), and the line shader applies u_color.a, so it blends into the background instead of sitting on it. Together that is about a fifth of the ink a major line leaves along its length, which is what gives the eye one grid to read instead of two. The major class is untouched: it stays the structure. Tests: a new pixel test (the_minor_grid_is_thinner_dashed_and_dimmer_than_the_major) asserts a major column is inked top-to-bottom while a minor one alternates, and that the minor's ink sits closer to the background than the major's. Three existing tests counted the minor class as "most of eight rows" of its exact colour; two now take their floor from the style (minor_line_ink: width x alpha x duty), and the width test states the dash and alpha away because widths are its subject. 361 cases, 0 failed.
This commit is contained in:
1 parent
f3fb500068
commit
01e410bd74
5 files changed
+202
-13
No files matched your search
+13
-4
@@ -798,7 +798,7 @@ void Renderer::draw_grid(const Plot& plot) {
|
||||
// to draw rather than being drawn transparent. Majors first, minors over them, as
|
||||
// the single group order always did. `LineBatch::clear()` keeps its capacity, so
|
||||
// the second pass re-uses the first one's storage.
|
||||
const auto draw_class = [&](bool major, bool visible, Color color, f32 width) {
|
||||
const auto draw_class = [&](bool major, bool visible, Color color, f32 width, Vec2 dash) {
|
||||
if (!visible) {
|
||||
return;
|
||||
}
|
||||
@@ -808,12 +808,21 @@ void Renderer::draw_grid(const Plot& plot) {
|
||||
}
|
||||
// Snapped: a grid line is chrome at a round *data* value, and a hairline that
|
||||
// straddles two columns reads as a grey smear and shimmers as the view pans.
|
||||
flush_lines(map, color, width, Vec2{}, true);
|
||||
flush_lines(map, color, width, dash, true);
|
||||
};
|
||||
draw_class(true, style_.grid_major_visible, style_.grid_major,
|
||||
style_.device(style_.grid_major_width));
|
||||
style_.device(style_.grid_major_width), Vec2{});
|
||||
// The minor grid's dash rides the same per-draw uniform the crosshair and a dashed trace use,
|
||||
// and `off == 0` is the solid default. Each line starts its own pattern (the dash distance is
|
||||
// per-segment), and every segment here is built from the range's minimum, so the dashes of the
|
||||
// vertical lines line up with each other -- the grid reads as one texture rather than as a
|
||||
// jumble of unrelated dashes.
|
||||
const Vec2 minor_dash = style_.grid_minor_dash_off > 0.0f
|
||||
? Vec2{style_.device(style_.grid_minor_dash_on),
|
||||
style_.device(style_.grid_minor_dash_off)}
|
||||
: Vec2{};
|
||||
draw_class(false, style_.grid_minor_visible, style_.grid_minor,
|
||||
style_.device(style_.grid_minor_width));
|
||||
style_.device(style_.grid_minor_width), minor_dash);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------- axis chrome
|
||||
|
||||
Reference in new issue
Block a user