@@ -3565,34 +3565,43 @@ void ImageDrawLineEx(Image *dst, Vector2 start, Vector2 end, int thick, Color co
3565
3565
int dx = x2 - x1 ;
3566
3566
int dy = y2 - y1 ;
3567
3567
3568
- // Draw the main line between (x1, y1) and (x2, y2)
3569
- ImageDrawLine (dst , x1 , y1 , x2 , y2 , color );
3570
-
3571
3568
// Determine if the line is more horizontal or vertical
3572
3569
if ((dx != 0 ) && (abs (dy /dx ) < 1 ))
3573
3570
{
3574
3571
// Line is more horizontal
3575
- // Calculate half the width of the line
3576
- int wy = (thick - 1 )* (int )sqrtf ((float )(dx * dx + dy * dy ))/(2 * abs (dx ));
3577
3572
3578
- // Draw additional lines above and below the main line
3579
- for (int i = 1 ; i <= wy ; i ++ )
3573
+ // How many additional lines to draw
3574
+ int wy = thick - 1 ;
3575
+
3576
+ // Draw the main line and lower half
3577
+ for (int i = 0 ; i <= ((wy + 1 )/2 ); i ++ )
3580
3578
{
3581
- ImageDrawLine (dst , x1 , y1 - i , x2 , y2 - i , color ); // Draw above the main line
3582
- ImageDrawLine (dst , x1 , y1 + i , x2 , y2 + i , color ); // Draw below the main line
3579
+ ImageDrawLine (dst , x1 , y1 + i , x2 , y2 + i , color );
3580
+ }
3581
+
3582
+ // Draw the upper half
3583
+ for (int i = 1 ; i <= (wy /2 ); i ++ )
3584
+ {
3585
+ ImageDrawLine (dst , x1 , y1 - i , x2 , y2 - i , color );
3583
3586
}
3584
3587
}
3585
3588
else if (dy != 0 )
3586
3589
{
3587
3590
// Line is more vertical or perfectly horizontal
3588
- // Calculate half the width of the line
3589
- int wx = (thick - 1 )* (int )sqrtf ((float )(dx * dx + dy * dy ))/(2 * abs (dy ));
3591
+
3592
+ // How many additional lines to draw
3593
+ int wx = thick - 1 ;
3594
+
3595
+ //Draw the main line and right half
3596
+ for (int i = 0 ; i <= ((wx + 1 )/2 ); i ++ )
3597
+ {
3598
+ ImageDrawLine (dst , x1 + i , y1 , x2 + i , y2 , color );
3599
+ }
3590
3600
3591
- // Draw additional lines to the left and right of the main line
3592
- for (int i = 1 ; i <= wx ; i ++ )
3601
+ // Draw the left half
3602
+ for (int i = 1 ; i <= ( wx / 2 ) ; i ++ )
3593
3603
{
3594
- ImageDrawLine (dst , x1 - i , y1 , x2 - i , y2 , color ); // Draw left of the main line
3595
- ImageDrawLine (dst , x1 + i , y1 , x2 + i , y2 , color ); // Draw right of the main line
3604
+ ImageDrawLine (dst , x1 - i , y1 , x2 - i , y2 , color );
3596
3605
}
3597
3606
}
3598
3607
}
0 commit comments