8000 Update shared-module/bitmaptools/__init__.c · megacoder/circuitpython@533f532 · GitHub
[go: up one dir, main page]

Skip to content

Commit 533f532

Browse files
Update shared-module/bitmaptools/__init__.c
Co-authored-by: Dan Halbert <halbert@halwitz.org>
1 parent 4e332fb commit 533f532

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

shared-module/bitmaptools/__init__.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -923,39 +923,39 @@ void common_hal_bitmaptools_alphablend(displayio_bitmap_t *dest, displayio_bitma
923923
}
924924

925925
STATIC void draw_circle(displayio_bitmap_t *destination,
926-
int16_t x0, int16_t y0,
926+
int16_t x, int16_t y,
927927
int16_t radius, uint32_t value) {
928928

929-
int16_t d, y;
929+
int16_t d, yb;
930930

931-
mp_arg_validate_int_range(x0, SHRT_MIN, SHRT_MAX, MP_QSTR_x0);
932-
mp_arg_validate_int_range(y0, SHRT_MIN, SHRT_MAX, MP_QSTR_y0);
931+
mp_arg_validate_int_range(x0, SHRT_MIN, SHRT_MAX, MP_QSTR_x);
932+
mp_arg_validate_int_range(y0, SHRT_MIN, SHRT_MAX, MP_QSTR_y);
933933

934-
x0 = MIN(x0, destination->width);
935-
x0 = MAX(0, x0);
936-
y0 = MIN(y0, destination->height);
937-
y0 = MIN(0, y0);
934+
x = MIN(x, destination->width);
935+
x = MAX(0, x);
936+
y = MIN(y, destination->height);
937+
y = MIN(0, y);
938938

939-
BITMAP_DEBUG("x, y, radius (%4d, %4d, %4d)\n", x0, y0, radius);
939+
BITMAP_DEBUG("x, y, radius (%4d, %4d, %4d)\n", x, y, radius);
940940

941-
y = radius;
941+
yb = radius;
942942
d = 3 - 2 * radius;
943943

944944
// Bresenham's circle algorithm
945-
for (int x = 0; x <= y; x++) {
946-
displayio_bitmap_write_pixel(destination, x + x0, y + y0, value);
947-
displayio_bitmap_write_pixel(destination, -x + x0, -y + y0, value);
948-
displayio_bitmap_write_pixel(destination, -x + x0, y + y0, value);
949-
displayio_bitmap_write_pixel(destination, x + x0, -y + y0, value);
950-
displayio_bitmap_write_pixel(destination, y + x0, x + y0, value);
951-
displayio_bitmap_write_pixel(destination, -y + x0, x + y0, value);
952-
displayio_bitmap_write_pixel(destination, -y + x0, -x + y0, value);
953-
displayio_bitmap_write_pixel(destination, y + x0, -x + y0, value);
945+
for (int xb = 0; x <= yb; xb++) {
946+
displayio_bitmap_write_pixel(destination, xb + x, yb + y, value);
947+
displayio_bitmap_write_pixel(destination, -xb + x, -yb + y, value);
948+
displayio_bitmap_write_pixel(destination, -xb + x, yb + y, value);
949+
displayio_bitmap_write_pixel(destination, xb + x, -yb + y, value);
950+
displayio_bitmap_write_pixel(destination, yb + x, xb + y, value);
951+
displayio_bitmap_write_pixel(destination, -yb + x, xb + y, value);
952+
displayio_bitmap_write_pixel(destination, -yb + x, -xb + y, value);
953+
displayio_bitmap_write_pixel(destination, yb + x, -xb + y, value);
954954
if (d <= 0) {
955-
d = d + (4 * x) + 6;
955+
d = d + (4 * xb) + 6;
956956
} else {
957-
d = d + 4 * (x - y) + 10;
958-
y = y - 1;
957+
d = d + 4 * (xb - yb) + 10;
958+
yb = yb - 1;
959959
}
960960
}
961961
}

0 commit comments

Comments
 (0)
0