File tree Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -91,19 +91,29 @@ pub fn draw_line<DB: DrawingBackend, S: BackendStyle>(
9191 }
9292 } ;
9393
94- let mut y = f64:: from ( from. 1 ) ;
94+ let y_step_limit =
95+ ( f64:: from ( to. 1 . min ( size_limit. 1 as i32 - 1 ) . max ( 0 ) - from. 1 ) / grad) . floor ( ) as i32 ;
9596
96- let y_step_limit = ( f64:: from ( to. 1 . min ( size_limit. 1 as i32 - 1 ) - from. 1 ) / grad) . ceil ( ) as i32 ;
97+ let batch_start = ( f64:: from ( from. 1 . min ( size_limit. 1 as i32 - 2 ) . max ( 0 ) - from. 1 ) / grad)
98+ . abs ( )
99+ . ceil ( ) as i32
100+ + from. 0 ;
97101
98- for x in from. 0 ..=to. 0 . min ( size_limit. 0 as i32 - 2 ) . min ( from. 0 + y_step_limit) {
102+ let batch_limit =
103+ to. 0 . min ( size_limit. 0 as i32 - 2 )
104+ . min ( from. 0 + y_step_limit - 1 ) ;
105+
106+ let mut y = f64:: from ( from. 1 ) + f64:: from ( batch_start - from. 0 ) * grad;
107+
108+ for x in batch_start..=batch_limit {
99109 check_result ! ( put_pixel( ( x, y as i32 ) , 1.0 + y. floor( ) - y) ) ;
100110 check_result ! ( put_pixel( ( x, y as i32 + 1 ) , y - y. floor( ) ) ) ;
101111
102112 y += grad;
103113 }
104114
105- if to. 0 >= ( size_limit . 0 as i32 ) - 1 && y < f64:: from ( to. 1 ) {
106- let x = size_limit . 0 as i32 - 1 ;
115+ if to. 0 >= batch_limit + 1 && y < f64:: from ( to. 1 ) {
116+ let x = batch_limit as i32 + 1 ;
107117 if 1.0 + y. floor ( ) - y > 1e-5 {
108118 check_result ! ( put_pixel( ( x, y as i32 ) , 1.0 + y. floor( ) - y) ) ;
109119 }
You can’t perform that action at this time.
0 commit comments