@@ -11,31 +11,54 @@ class RealLineGraph extends RealRenderer {
1111 this . progressiveAxis = this . progressiveAxis . toLowerCase ( ) ;
1212 this . progressionMode = options . progressionMode || 'overflow' ; // overflow -> Only progresses when completely filled; continous -> Always progresses;
1313 this . progressInterval = options . progressInterval || 1 ; // Progress once every interval time units; Only works with continous progressionMode
14+
1415 this . brushSize = options . brushSize || 2 ; // 1 unit radius
1516 this . brushColor = options . brushColor || [ 1 , 1 , 1 ] ;
17+
18+ this . lineThickness = options . lineThickness || 0.05 ;
19+ this . lineColor = options . lineColor || [ 0 , 0.5 , 0 ] ;
1620 // *****DEFAULTS*****
1721
1822 this . _progressGraph = getProgressGraphKernel ( this . gpu , this . dimensions , this . progressiveAxis , this . xOffset , this . yOffset , this . axesColor , this . bgColor ) ;
1923 this . _lastProgress = 0 ; // Time when the graph last progressed. Internal variable
24+ this . _numProgress = 0 ; // Number of times the graph has progressed
2025
21- this . _dataIndex = 0 ; // Number of plots
26+ this . _dataIndex = 1 ; // Number of plots
2227 this . _lastData = 0 ; // (Value) To display lines
2328
24- this . _addData = getAddDataKernel ( this . gpu , this . dimensions , this . brushSize , this . brushColor , this . xScaleFactor , this . yScaleFactor , this . xOffset , this . yOffset ) ;
29+ this . _addData = getAddDataKernel ( this . gpu , this . dimensions , this . brushSize , this . brushColor , this . xScaleFactor , this . yScaleFactor , this . xOffset , this . yOffset , this . lineThickness , this . lineColor ) ;
30+
31+ this . limits = { // Final ranges of x and y
32+ x : [
33+ 0 - ( this . yOffset / 100 ) * ( this . dimensions [ 0 ] / this . xScaleFactor ) , // lower limit
34+ this . dimensions [ 0 ] / this . xScaleFactor - ( this . yOffset / 100 ) * ( this . dimensions [ 0 ] / this . xScaleFactor ) // upper limit
35+ ] ,
36+ y : [
37+ 0 - ( this . xOffset / 100 ) * ( this . dimensions [ 1 ] / this . yScaleFactor ) ,
38+ this . dimensions [ 1 ] / this . yScaleFactor - ( this . xOffset / 100 ) * ( this . dimensions [ 1 ] / this . yScaleFactor )
39+ ]
40+ }
2541 }
2642
2743 addData ( value ) {
28- this . graphPixels = this . _addData ( this . _cloneTexture ( this . graphPixels ) , value , this . _dataIndex ++ , this . _lastData ) ;
29- this . _display ( this . graphPixels ) ;
30-
44+ this . graphPixels = this . _addData ( this . _cloneTexture ( this . graphPixels ) , value , this . _dataIndex ++ , this . _lastData , this . _numProgress ) ;
3145 this . _lastData = value ;
46+
47+ // Overflow
48+ if ( this . _dataIndex >= this . limits . x [ 1 ] && this . progressionMode != 'continous' ) {
49+ this . graphPixels = this . _progressGraph ( this . _cloneTexture ( this . graphPixels ) , Math . ceil ( this . xScaleFactor ) )
50+ this . _numProgress += Math . ceil ( this . xScaleFactor ) ;
51+ }
52+
53+ this . _display ( this . graphPixels ) ;
3254 return this ;
3355 }
3456
3557 _drawFunc ( graphPixels , time ) {
3658 if ( this . progressionMode == 'continous' && ( time - this . _lastProgress >= this . progressInterval ) ) {
3759 this . _lastProgress = time ;
38- return this . _progressGraph ( this . _cloneTexture ( graphPixels ) ) ;
60+ this . _numProgress ++ ;
61+ return this . _progressGraph ( this . _cloneTexture ( graphPixels ) , 1 ) ;
3962 }
4063 else return graphPixels ;
4164 }
0 commit comments