feat: a repaired invalid span is shaded faintly, not solidly

This commit is contained in:
Martino Ferrari committed 2026-10-08 22:59:07 +02:00
1 parent ebc67bd318
commit 1fc97d818f
7 files changed
+152 -25

No files matched your search

+5 -5
View File
@@ -344,7 +344,7 @@ void Plot::set_y_axis_origin_from_range(u32 axis, bool on) {
void Plot::set_x_note(std::string text) { x_note_ = std::move(text); }
void Plot::set_invalid_spans(std::span<const std::pair<f64, f64>> spans) {
void Plot::set_invalid_spans(std::span<const InvalidSpan> spans) {
invalid_spans_.assign(spans.begin(), spans.end());
}
@@ -1378,9 +1378,9 @@ void Plot::build_invalid_spans() {
// the band is most needed for. One device pixel is the floor.
const f32 min_w = std::max(1.0f, style_.device(1.0f));
for (const std::pair<f64, f64>& span : invalid_spans_) {
const f64 a = std::min(span.first, span.second);
const f64 b = std::max(span.first, span.second);
for (const InvalidSpan& span : invalid_spans_) {
const f64 a = std::min(span.x0, span.x1);
const f64 b = std::max(span.x0, span.x1);
if (!std::isfinite(a) || !std::isfinite(b)) continue;
const f32 lo = static_cast<f32>(tx.to_screen_x(a));
const f32 hi = static_cast<f32>(tx.to_screen_x(b));
@@ -1394,7 +1394,7 @@ void Plot::build_invalid_spans() {
// Widening a band at the right edge would run it over the axis line, so the floor is taken
// out of the left instead: the span's own edge is kept wherever there is room for it.
const f32 x = std::clamp(first, axes.x, axes.right() - w);
layout_.invalid_spans.push_back(Rect{x, axes.y, w, axes.h});
layout_.invalid_spans.push_back(InvalidSpanLayout{Rect{x, axes.y, w, axes.h}, span.repaired});
}
}