-
Notifications
You must be signed in to change notification settings - Fork 981
Closed
Description
Extend work started in #2935 to create code that draws lines more carefully and has features like edge interpolation. It can later be used by SignalXY plots too.
Here is relevant code from ScottPlot4:
ScottPlot/src/ScottPlot4/ScottPlot/Plottable/SignalPlotXYGeneric.cs
Lines 198 to 227 in 85e982e
| PointF[] PointsToDraw = PointBefore.Concat(VisiblePoints).Concat(PointAfter).ToArray(); | |
| // Interpolate before displayed point to make it x = -1 (close to visible area) | |
| // this fix extreme zoom in bug | |
| if (PointBefore.Length > 0 && PointsToDraw.Length >= 2 && !StepDisplay) | |
| { | |
| // only extrapolate if points are different (otherwise extrapolated point may be infinity) | |
| if (PointsToDraw[0].X != PointsToDraw[1].X) | |
| { | |
| float x0 = -1 + dims.DataOffsetX; | |
| float y0 = PointsToDraw[1].Y + (PointsToDraw[0].Y - PointsToDraw[1].Y) * (x0 - PointsToDraw[1].X) / (PointsToDraw[0].X - PointsToDraw[1].X); | |
| PointsToDraw[0] = new PointF(x0, y0); | |
| } | |
| } | |
| // Interpolate after displayed point to make it x = datasize.Width(close to visible area) | |
| // this fix extreme zoom in bug | |
| if (PointAfter.Length > 0 && PointsToDraw.Length >= 2 && !StepDisplay) | |
| { | |
| PointF lastPoint = PointsToDraw[PointsToDraw.Length - 2]; | |
| PointF afterPoint = PointsToDraw[PointsToDraw.Length - 1]; | |
| // only extrapolate if points are different (otherwise extrapolated point may be infinity) | |
| if (afterPoint.X != lastPoint.X) | |
| { | |
| float x1 = dims.DataWidth + dims.DataOffsetX; | |
| float y1 = lastPoint.Y + (afterPoint.Y - lastPoint.Y) * (x1 - lastPoint.X) / (afterPoint.X - lastPoint.X); | |
| PointsToDraw[PointsToDraw.Length - 1] = new PointF(x1, y1); | |
| } | |
| } |
EDIT: see #2935 (comment) for more information
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
