@@ -87,15 +87,16 @@ impl Stream {
8787 let color = gradient. interpolate ( i as f32 / self . count as f32 ) ;
8888
8989 // Determine the entity starting x and y positions based on the direction of flow
90+ let width_adjusted_i = i as f32 * config. mode . width ( ) as f32 ;
9091 let ( x, y) = match config. direction {
9192 Direction :: Down => ( self . x , self . y - i as f32 ) ,
9293 Direction :: Up => ( self . x , self . y + i as f32 ) ,
93- Direction :: Right => ( self . x - i as f32 , self . y ) ,
94- Direction :: Left => ( self . x + i as f32 , self . y ) ,
95- Direction :: DiagonalRight => ( self . x - i as f32 , self . y - i as f32 ) ,
96- Direction :: DiagonalRightReverse => ( self . x + i as f32 , self . y + i as f32 ) ,
97- Direction :: DiagonalLeft => ( self . x + i as f32 , self . y - i as f32 ) ,
98- Direction :: DiagonalLeftReverse => ( self . x - i as f32 , self . y + i as f32 ) ,
94+ Direction :: Right => ( self . x - width_adjusted_i , self . y ) ,
95+ Direction :: Left => ( self . x + width_adjusted_i , self . y ) ,
96+ Direction :: DiagonalRight => ( self . x - width_adjusted_i , self . y - i as f32 ) ,
97+ Direction :: DiagonalRightReverse => ( self . x + width_adjusted_i , self . y + i as f32 ) ,
98+ Direction :: DiagonalLeft => ( self . x + width_adjusted_i , self . y - i as f32 ) ,
99+ Direction :: DiagonalLeftReverse => ( self . x - width_adjusted_i , self . y + i as f32 ) ,
99100 } ;
100101
101102 // Create the entity and add it to the entities vector
@@ -118,22 +119,27 @@ impl Stream {
118119 // Clean up the last entity. As the stream moves down, all entities will be overwritten
119120 // by the next frame, except for the trailing entity. So we manually overwrite it so that
120121 // the stream doesn't leave a trail.
121- if !config. leave_trail {
122+ if !config. leave_trail && e. x >= 0.0 {
123+ let space = " " . repeat ( config. mode . width ( ) ) ;
122124 stdout
123125 . queue ( cursor:: MoveTo ( e. x as u16 , e. y as u16 ) ) ?
124- . queue ( Print ( " " ) ) ?;
126+ . queue ( Print ( space ) ) ?;
125127 }
126128
127129 // This is also a good time to check if the last entity is off the screen,
128130 // and if it is, we regenerate the stream and place it back at the top.
129131 let should_regenerate = match config. direction {
130132 Direction :: Down => e. y >= rows as f32 ,
131133 Direction :: Up => e. y < 0.0 ,
132- Direction :: Right => e. x >= columns as f32 ,
133- Direction :: Left => e. x < 0.0 ,
134+ Direction :: Right => e. x + e . width ( ) as f32 >= columns as f32 ,
135+ Direction :: Left => e. x + ( e . width ( ) as f32 ) < 0.0 ,
134136 Direction :: DiagonalLeft => e. x < 0.0 && e. y >= rows as f32 ,
135- Direction :: DiagonalLeftReverse => e. x >= columns as f32 && e. y < 0.0 ,
136- Direction :: DiagonalRight => e. x >= columns as f32 && e. y >= rows as f32 ,
137+ Direction :: DiagonalLeftReverse => {
138+ e. x + e. width ( ) as f32 >= columns as f32 && e. y < 0.0
139+ }
140+ Direction :: DiagonalRight => {
141+ e. x + e. width ( ) as f32 >= columns as f32 && e. y >= rows as f32
142+ }
137143 Direction :: DiagonalRightReverse => e. x < 0.0 && e. y < 0.0 ,
138144 } ;
139145
0 commit comments