Skip to content

Commit f4e27c7

Browse files
committed
Explicitly using floats in math
1 parent 4356cd4 commit f4e27c7

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

src_c/draw.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2478,7 +2478,7 @@ draw_eight_symetric_pixels(SDL_Surface *surf, int x0, int y0, Uint32 color,
24782478
int top_left, int bottom_left, int bottom_right,
24792479
int *drawn_area)
24802480
{
2481-
opacity = opacity / 255;
2481+
opacity = opacity / 255.0f;
24822482
Uint32 pixel_color;
24832483
if (top_right == 1) {
24842484
pixel_color =
@@ -2526,11 +2526,11 @@ draw_circle_xaolinwu(SDL_Surface *surf, int x0, int y0, int radius,
25262526
for (int radius_ = radius - thickness; radius_ <= radius; radius_++) {
25272527
int x = 0;
25282528
int y = radius_;
2529-
double prev_opacity = 0;
2529+
double prev_opacity = 0.0;
25302530
if (radius_ == radius - thickness) {
25312531
while (x < y) {
25322532
double height = sqrt(pow(radius_, 2) - pow(x, 2));
2533-
double opacity = 255 * (ceil(height) - height);
2533+
double opacity = 255.0f * (ceil(height) - height);
25342534
if (opacity < prev_opacity) {
25352535
--y;
25362536
}
@@ -2547,14 +2547,15 @@ draw_circle_xaolinwu(SDL_Surface *surf, int x0, int y0, int radius,
25472547
else if (radius_ == radius) {
25482548
while (x < y) {
25492549
double height = sqrt(pow(radius_, 2) - pow(x, 2));
2550-
double opacity = 255 * (ceil(height) - height);
2550+
double opacity = 255.0f * (ceil(height) - height);
25512551
if (opacity < prev_opacity) {
25522552
--y;
25532553
}
25542554
prev_opacity = opacity;
2555-
draw_eight_symetric_pixels(
2556-
surf, x0, y0, color, x, y, 255 - (float)opacity, top_right,
2557-
top_left, bottom_left, bottom_right, drawn_area);
2555+
draw_eight_symetric_pixels(surf, x0, y0, color, x, y,
2556+
255.0f - (float)opacity, top_right,
2557+
top_left, bottom_left, bottom_right,
2558+
drawn_area);
25582559
draw_eight_symetric_pixels(
25592560
surf, x0, y0, color, x, y - 1, 255.0f, top_right, top_left,
25602561
bottom_left, bottom_right, drawn_area);
@@ -2564,7 +2565,7 @@ draw_circle_xaolinwu(SDL_Surface *surf, int x0, int y0, int radius,
25642565
else {
25652566
while (x < y) {
25662567
double height = sqrt(pow(radius_, 2) - pow(x, 2));
2567-
double opacity = 255 * (ceil(height) - height);
2568+
double opacity = 255.0f * (ceil(height) - height);
25682569
if (opacity < prev_opacity) {
25692570
--y;
25702571
}
@@ -2588,17 +2589,17 @@ draw_circle_xaolinwu_thin(SDL_Surface *surf, int x0, int y0, int radius,
25882589
{
25892590
int x = 0;
25902591
int y = radius;
2591-
double prev_opacity = 0;
2592+
double prev_opacity = 0.0;
25922593
while (x < y) {
25932594
double height = sqrt(pow(radius, 2) - pow(x, 2));
2594-
double opacity = 255 * (ceil(height) - height);
2595+
double opacity = 255.0f * (ceil(height) - height);
25952596
if (opacity < prev_opacity) {
25962597
--y;
25972598
}
25982599
prev_opacity = opacity;
2599-
draw_eight_symetric_pixels(surf, x0, y0, color, x, y,
2600-
255 - (float)opacity, top_right, top_left,
2601-
bottom_left, bottom_right, drawn_area);
2600+
draw_eight_symetric_pixels(
2601+
surf, x0, y0, color, x, y, 255.0f - (float)opacity, top_right,
2602+
top_left, bottom_left, bottom_right, drawn_area);
26022603
draw_eight_symetric_pixels(surf, x0, y0, color, x, y - 1,
26032604
(float)opacity, top_right, top_left,
26042605
bottom_left, bottom_right, drawn_area);

0 commit comments

Comments
 (0)