@@ -116,10 +116,13 @@ fn x_perpendicular(
116116
117117 let ( c1, c2) = ( Rgb565 :: GREEN , Rgb565 :: GREEN ) ;
118118
119- while tk. pow ( 2 ) <= width_l + ( tk * 2 * delta. major ) && width_l > 0 {
120- let thing = tk. pow ( 2 ) as f32 / width_l as f32 ;
121- let fract = 1.0 - thing;
122- dbg ! ( fract) ;
119+ while tk. pow ( 2 ) <= width_l + tk. pow ( 2 ) && width_l > 0 {
120+ let thing = ( tk. pow ( 2 ) - width_l) as f32 / width_l as f32 ;
121+ let fract = if tk. pow ( 2 ) > width_l {
122+ 1.0 - thing
123+ } else {
124+ 1.0
125+ } ;
123126
124127 Pixel (
125128 point,
@@ -140,35 +143,31 @@ fn x_perpendicular(
140143 error += e_major;
141144 point += step. minor ;
142145 tk += 2 * dx;
143-
144- // // Antialiasing
145- // {
146- // let thing = tk.pow(2) as f32 / width_l as f32;
147-
148- // if thing >= 1.0 {
149- // let fract = 1.0 - thing.fract();
150-
151- // Pixel(
152- // point,
153- // Rgb565::new(
154- // (c1.r() as f32 * fract) as u8,
155- // (c1.g() as f32 * fract) as u8,
156- // (c1.b() as f32 * fract) as u8,
157- // ),
158- // )
159- // .draw(display)?;
160- // }
161- // }
162146 }
163147
164148 let mut point = Point :: new ( x0, y0) ;
165149 let mut error = -einit;
166150 let mut tk = winit;
167151 let mut p = 0 ;
168152
169- while tk. pow ( 2 ) <= width_r && width_r > 0 {
153+ while tk. pow ( 2 ) <= width_r + tk . pow ( 2 ) && width_r > 0 {
170154 if p > 0 {
171- Pixel ( point, c2) . draw ( display) ?;
155+ let thing = ( tk. pow ( 2 ) - width_l) as f32 / width_l as f32 ;
156+ let fract = if tk. pow ( 2 ) > width_l {
157+ 1.0 - thing
158+ } else {
159+ 1.0
160+ } ;
161+
162+ Pixel (
163+ point,
164+ Rgb565 :: new (
165+ ( c1. r ( ) as f32 * fract) as u8 ,
166+ ( c1. g ( ) as f32 * fract) as u8 ,
167+ ( c1. b ( ) as f32 * fract) as u8 ,
168+ ) ,
169+ )
170+ . draw ( display) ?;
172171 }
173172
174173 if error > threshold {
@@ -181,25 +180,6 @@ fn x_perpendicular(
181180 point -= step. minor ;
182181 tk += 2 * dx;
183182 p += 1 ;
184-
185- // Antialiasing
186- {
187- let thing = tk. pow ( 2 ) as f32 / width_r as f32 ;
188-
189- if thing > 1.0 {
190- let fract = 1.0 - thing. fract ( ) ;
191-
192- Pixel (
193- point,
194- Rgb565 :: new (
195- ( c2. r ( ) as f32 * fract) as u8 ,
196- ( c2. g ( ) as f32 * fract) as u8 ,
197- ( c2. b ( ) as f32 * fract) as u8 ,
198- ) ,
199- )
200- . draw ( display) ?;
201- }
202- }
203183 }
204184
205185 Ok ( ( ) )
@@ -231,7 +211,7 @@ fn x_varthick_line(
231211 display, point. x , point. y , delta, pstep, p_error, width, error, false ,
232212 ) ?;
233213
234- Pixel ( point, Rgb565 :: WHITE ) . draw ( display) ?;
214+ // Pixel(point, Rgb565::WHITE).draw(display)?;
235215
236216 if error > threshold {
237217 point += step. minor ;
@@ -251,7 +231,7 @@ fn x_varthick_line(
251231 true ,
252232 ) ?;
253233
254- Pixel ( point, Rgb565 :: BLACK ) . draw ( display) ?;
234+ // Pixel(point, Rgb565::BLACK).draw(display)?;
255235 }
256236
257237 p_error += e_minor;
0 commit comments