feat: a repaired invalid span is shaded faintly, not solidly
This commit is contained in:
1 parent
ebc67bd318
commit
1fc97d818f
7 files changed
+152
-25
No files matched your search
+5
-5
@@ -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});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1732,8 +1732,8 @@ void Renderer::draw_cursor_label(const Plot& plot, const PlotLayout& layout, con
|
||||
}
|
||||
|
||||
void Renderer::draw_invalid_spans(const PlotLayout& layout) {
|
||||
for (const Rect& band : layout.invalid_spans) {
|
||||
if (band.w > 0.0f) fill_pixels(band, style_.invalid_fill);
|
||||
for (const InvalidSpanLayout& band : layout.invalid_spans) {
|
||||
fill_pixels(band.fill, band.repaired ? style_.invalid_repaired_fill : style_.invalid_fill);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user