feat(plot): the figure crosshair marks the hovered row, and the stroke is thin, dashed and configurable
This commit is contained in:
1 parent
cae672bc99
commit
eee7c34dd5
12 files changed
+166
-12
No files matched your search
@@ -27,6 +27,11 @@ class LineProgram {
|
||||
void set_viewport(Vec2 px) const noexcept;
|
||||
/// `u_width`: stroke width in pixels.
|
||||
void set_width(f32 px) const noexcept;
|
||||
/// `u_dash`: the dash pattern in pixels -- `x` the ink length, `y` the gap, and a
|
||||
/// non-positive `y` (the default a caller passes) means **solid**. It is a fragment-shader
|
||||
/// discard on the interpolated `v_along`, so it costs no geometry, and it is the one uniform
|
||||
/// that distinguishes the crosshair's stroke from every other line in the library.
|
||||
void set_dash(Vec2 on_off) const noexcept;
|
||||
/// `u_color`: stroke colour, alpha included.
|
||||
void set_color(Color color) const noexcept;
|
||||
|
||||
|
||||
@@ -365,7 +365,12 @@ class Renderer {
|
||||
/// Uploads the staged line batch, maps it with (`scale`, `offset`), rasterises
|
||||
/// it in one colour and empties the batch. A no-op for an empty batch, so the
|
||||
/// caller can flush unconditionally.
|
||||
void flush_lines(const Mapping& map, Color color, f32 width) noexcept;
|
||||
///
|
||||
/// `dash` is the pattern in pixels for the fragment shader's discard: `x` the ink
|
||||
/// length, `y` the gap, and a non-positive `y` -- the default every caller but the
|
||||
/// crosshair passes -- means **solid**. It is set on every flush, so one draw's dash
|
||||
/// can never leak into the next.
|
||||
void flush_lines(const Mapping& map, Color color, f32 width, Vec2 dash = Vec2{}) noexcept;
|
||||
/// Draws every staged glyph in `style().axis_text` and empties the batch. Text
|
||||
/// is texture-bound, so this runs once per frame, after all line geometry.
|
||||
void flush_text() noexcept;
|
||||
|
||||
@@ -54,6 +54,21 @@ struct Style {
|
||||
/// already distinct, so no dashes.
|
||||
Color crosshair = Color::hex(0xE6EBF2);
|
||||
|
||||
/// The crosshair's stroke and dash, in logical pixels (spec §17). The crosshair is a
|
||||
/// *passive* hover instrument drawn over the data, so its default **recedes**: a
|
||||
/// thinner stroke than a trace's (`Trace::width`'s 1.5) so it reads as chrome rather
|
||||
/// than as data, and a dash so it is distinguishable from the grid and the traces at
|
||||
/// a glance.
|
||||
///
|
||||
/// `crosshair_dash_on` is the ink length and `crosshair_dash_off` the gap; **`off == 0`
|
||||
/// means solid**, which is the value every *other* line in the library is drawn at, so
|
||||
/// the one pipeline serves them unchanged (the dash is a fragment-shader discard on
|
||||
/// `v_along`, so no geometry is added). A `Crosshair` may override all three for one
|
||||
/// plot without touching this global style.
|
||||
f32 crosshair_width = 0.75f;
|
||||
f32 crosshair_dash_on = 4.0f;
|
||||
f32 crosshair_dash_off = 4.0f;
|
||||
|
||||
// --- the scale ----------------------------------------------------------
|
||||
|
||||
/// Device pixels per logical unit. 1.0 is the 1x display every default here was
|
||||
|
||||
Reference in new issue
Block a user