toolkit: TimeSeriesChart's curve stops staircasing - #456
Merged
Conversation
toolkit's chart curves are drawn with Bresenham's algorithm — no partial coverage, visibly staircased on a diagonal. painter.PixelPainter already supports anti-aliased strokes via StrokePath, so this adds drawCurveLine: a PathPainter fast path (an AA stroke) for TimeSeriesChart's own diagonal segments (the main curve and the dashed Threshold line), falling back to the shared drawLine unchanged everywhere else. Deliberately scoped to TimeSeriesChart, not the shared drawLine itself: an early attempt to anti-alias drawLine broke TestWidgetsStayWithinBounds (a 1-unit AA stroke centred on an integer coordinate straddles the pixel boundary and bleeds half a pixel past a widget's own Bounds) and TestMetricScaleAudit across LineChart/BarChart/AreaChart/ScatterChart — real regressions on axis-aligned gridlines/rules, not just outdated pixel-exact test expectations. A diagonal segment inside a plot area carries no such bounds risk, and is exactly the case where staircasing is visible. Segment color selection (segmentInk) is pulled out of Draw into its own plain function so OverInk's decision logic can be tested exactly — an anti-aliased pixel is a coverage blend, never a pure color match, which makes sampling drawn pixels the wrong tool for that specific question. Several existing pixel-exact tests are rewritten the same way: compare two renders (or count "differs from the untouched sentinel", not "equals this exact color") rather than assume Bresenham's single opaque pixel. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TimeSeriesChart's curve and dashed Threshold line were visibly jagged — plain Bresenham, no anti-aliasing (live user feedback: "il ne semble pas y avoir d'anti-crénelage sur les courbes des graphes?").drawCurveLine: strokes an anti-aliased path viapainter.PathPainter.StrokePathon a GUI back-end, falling back to the shareddrawLineunchanged on aCellPainter(TUI).TimeSeriesChart's own diagonal segments, not the shareddrawLine. An initial attempt to anti-aliasdrawLineitself brokeTestWidgetsStayWithinBounds(a 1-unit AA stroke centered on an integer coordinate straddles the pixel boundary and bleeds half a pixel past a widget's ownBounds) andTestMetricScaleAuditacrossLineChart/BarChart/AreaChart/ScatterChart— real regressions on axis-aligned gridlines/rules, not just outdated test expectations. A diagonal curve segment inside a plot area carries no such bounds risk.segmentInk(the OverInk-above-threshold color decision) is pulled out ofDrawinto its own plain function so it can be tested exactly, since an anti-aliased pixel is a coverage blend and sampling for an exact color match is the wrong tool for that question. Several existing pixel-exactTimeSeriesCharttests are rewritten the same way (compare two renders, or check "differs from the sentinel," rather than assume an opaque Bresenham pixel).Test plan
go build ./...,go vet ./...,gofmt -l .cleango test ./...green across the whole repo — confirmed zero regressions in every OTHER widget after scoping down from the broken toolkit-wide attempttimeserieschart.go(and its tests) at 100% coverage, including the CellPainter fallback branch🤖 Generated with Claude Code