45 lines
918 B
C
45 lines
918 B
C
#define plot(x, y) put_pixel_clip(img, x, y, r, g, b)
|
|
|
|
void raster_circle(
|
|
image img,
|
|
unsigned int x0,
|
|
unsigned int y0,
|
|
unsigned int radius,
|
|
color_component r,
|
|
color_component g,
|
|
color_component b )
|
|
{
|
|
int f = 1 - radius;
|
|
int ddF_x = 0;
|
|
int ddF_y = -2 * radius;
|
|
int x = 0;
|
|
int y = radius;
|
|
|
|
plot(x0, y0 + radius);
|
|
plot(x0, y0 - radius);
|
|
plot(x0 + radius, y0);
|
|
plot(x0 - radius, y0);
|
|
|
|
while(x < y)
|
|
{
|
|
if(f >= 0)
|
|
{
|
|
y--;
|
|
ddF_y += 2;
|
|
f += ddF_y;
|
|
}
|
|
x++;
|
|
ddF_x += 2;
|
|
f += ddF_x + 1;
|
|
plot(x0 + x, y0 + y);
|
|
plot(x0 - x, y0 + y);
|
|
plot(x0 + x, y0 - y);
|
|
plot(x0 - x, y0 - y);
|
|
plot(x0 + y, y0 + x);
|
|
plot(x0 - y, y0 + x);
|
|
plot(x0 + y, y0 - x);
|
|
plot(x0 - y, y0 - x);
|
|
}
|
|
}
|
|
#undef plot
|