@@ -253,18 +253,35 @@ impl Data {
253
253
let end_y =
254
254
( ( message. y + height as u16 ) . min ( RESOLUTION_HEIGHT as u16 - 1 ) ) as usize ;
255
255
256
- for x in start_x..=end_x {
257
- let top_index = start_y * RESOLUTION_WIDTH * 3 + x * 3 ;
258
- let bottom_index = end_y * RESOLUTION_WIDTH * 3 + x * 3 ;
259
- self_data[ top_index..top_index + 3 ] . copy_from_slice ( & message. color ) ;
260
- self_data[ bottom_index..bottom_index + 3 ] . copy_from_slice ( & message. color ) ;
256
+ for offset in 0 ..2 {
257
+ for x in start_x..=end_x {
258
+ if ( start_y + offset) < RESOLUTION_HEIGHT {
259
+ let top_index = ( start_y + offset) * RESOLUTION_WIDTH * 3 + x * 3 ;
260
+ self_data[ top_index..top_index + 3 ] . copy_from_slice ( & message. color ) ;
261
+ }
262
+
263
+ if ( end_y + offset) < RESOLUTION_HEIGHT {
264
+ let bottom_index = ( end_y + offset) * RESOLUTION_WIDTH * 3 + x * 3 ;
265
+ self_data[ bottom_index..bottom_index + 3 ]
266
+ . copy_from_slice ( & message. color ) ;
267
+ }
268
+ }
261
269
}
262
270
263
- for y in start_y..=end_y {
264
- let left_index = y * RESOLUTION_WIDTH * 3 + start_x * 3 ;
265
- let right_index = y * RESOLUTION_WIDTH * 3 + end_x * 3 ;
266
- self_data[ left_index..left_index + 3 ] . copy_from_slice ( & message. color ) ;
267
- self_data[ right_index..right_index + 3 ] . copy_from_slice ( & message. color ) ;
271
+ for offset in 0 ..2 {
272
+ for y in start_y..=end_y {
273
+ if ( start_x + offset) < RESOLUTION_WIDTH {
274
+ let left_index = y * RESOLUTION_WIDTH * 3 + ( start_x + offset) * 3 ;
275
+ self_data[ left_index..left_index + 3 ]
276
+ . copy_from_slice ( & message. color ) ;
277
+ }
278
+
279
+ if ( end_x + offset) < RESOLUTION_WIDTH {
280
+ let right_index = y * RESOLUTION_WIDTH * 3 + ( end_x + offset) * 3 ;
281
+ self_data[ right_index..right_index + 3 ]
282
+ . copy_from_slice ( & message. color ) ;
283
+ }
284
+ }
268
285
}
269
286
}
270
287
Action :: DrawCircleNormal | Action :: DrawCircleHollow => {
@@ -281,20 +298,40 @@ impl Data {
281
298
let center_x = message. x as f32 ;
282
299
let center_y = message. y as f32 ;
283
300
let radius_sq = ( radius * radius) as f32 ;
284
- let inner_radius_sq = ( ( radius - 1 ) * ( radius - 1 ) ) as f32 ;
285
301
286
- for y in start_y..=end_y {
287
- let dy = y as f32 - center_y;
288
- let dy_sq = dy * dy;
289
- let row_start = y * RESOLUTION_WIDTH * 3 ;
302
+ if is_hollow {
303
+ let outer_radius_sq = radius_sq;
304
+ let inner_radius_sq = ( ( radius - 2 ) * ( radius - 2 ) ) as f32 ;
290
305
291
- for x in start_x..=end_x {
292
- let dx = x as f32 - center_x;
293
- let dist_sq = dx * dx + dy_sq;
306
+ for y in start_y..=end_y {
307
+ let dy = y as f32 - center_y;
308
+ let dy_sq = dy * dy;
309
+ let row_start = y * RESOLUTION_WIDTH * 3 ;
310
+
311
+ for x in start_x..=end_x {
312
+ let dx = x as f32 - center_x;
313
+ let dist_sq = dx * dx + dy_sq;
314
+
315
+ if dist_sq <= outer_radius_sq && dist_sq >= inner_radius_sq {
316
+ let index = row_start + x * 3 ;
317
+ self_data[ index..index + 3 ] . copy_from_slice ( & message. color ) ;
318
+ }
319
+ }
320
+ }
321
+ } else {
322
+ for y in start_y..=end_y {
323
+ let dy = y as f32 - center_y;
324
+ let dy_sq = dy * dy;
325
+ let row_start = y * RESOLUTION_WIDTH * 3 ;
326
+
327
+ for x in start_x..=end_x {
328
+ let dx = x as f32 - center_x;
329
+ let dist_sq = dx * dx + dy_sq;
294
330
295
- if ( dist_sq >= inner_radius_sq || !is_hollow) && dist_sq <= radius_sq {
296
- let index = row_start + x * 3 ;
297
- self_data[ index..index + 3 ] . copy_from_slice ( & message. color ) ;
331
+ if dist_sq <= radius_sq {
332
+ let index = row_start + x * 3 ;
333
+ self_data[ index..index + 3 ] . copy_from_slice ( & message. color ) ;
334
+ }
298
335
}
299
336
}
300
337
}
0 commit comments