@@ -244,11 +244,12 @@ public void Draw(Rect screenRect, double time)
244244
245245 for ( int pointIndex = 0 ; pointIndex < pointCount ; ++ pointIndex )
246246 {
247- var dataPoint = points [ pointIndex ] ;
248- if ( dataPoint . x > mintime )
249- actualXY [ pointIndex ] = new Vector2 (
250- ( float ) JUtil . DualLerp ( screenRect . xMin , screenRect . xMax , mintime , time , dataPoint . x ) ,
251- ( float ) JUtil . DualLerp ( screenRect . yMin , screenRect . yMax , verticalSpan . x , verticalSpan . y , dataPoint . y ) ) ;
247+ int sourcePointIndex = ( nextPoint + pointIndex - pointCount + maxPoints ) % maxPoints ;
248+
249+ var dataPoint = points [ sourcePointIndex ] ;
250+ actualXY [ pointIndex ] = new Vector2 (
251+ ( float ) JUtil . DualLerp ( screenRect . xMin , screenRect . xMax , mintime , time , dataPoint . x ) ,
252+ ( float ) JUtil . DualLerp ( screenRect . yMin , screenRect . yMax , verticalSpan . x , verticalSpan . y , dataPoint . y ) ) ;
252253 }
253254 DrawVector ( actualXY , pointCount , lineColor ) ;
254255 }
@@ -261,11 +262,15 @@ public void Update(double time)
261262 return ;
262263 }
263264 points [ nextPoint ++ ] = new Vector2d ( time , value ) ;
264- ++ pointCount ;
265+
266+ if ( pointCount < maxPoints )
267+ {
268+ ++ pointCount ;
269+ }
270+
265271 if ( nextPoint == maxPoints )
266272 {
267273 nextPoint = 0 ;
268- pointCount = maxPoints ;
269274 }
270275 }
271276
0 commit comments