41 lines
1.4 KiB
C
41 lines
1.4 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ML_filled_circle.c */
|
|
/* | Project : libmonochrome */
|
|
/* */
|
|
/* By: Pierre "PierrotLL" Le Gall <legallpierre89@gmail.com> */
|
|
/* Last updated: 2011/11/22 */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include <monochrome/internals.h>
|
|
|
|
void ML_filled_circle(int x, int y, int radius, ML_Color color)
|
|
{
|
|
int plot_x, plot_y, d;
|
|
|
|
if(radius < 0) return;
|
|
plot_x = 0;
|
|
plot_y = radius;
|
|
d = 1 - radius;
|
|
|
|
ML_horizontal_line(y, x-plot_y, x+plot_y, color);
|
|
while(plot_y > plot_x)
|
|
{
|
|
if(d < 0)
|
|
d += 2*plot_x+3;
|
|
else {
|
|
d += 2*(plot_x-plot_y)+5;
|
|
plot_y--;
|
|
ML_horizontal_line(y+plot_y+1, x-plot_x, x+plot_x, color);
|
|
ML_horizontal_line(y-plot_y-1, x-plot_x, x+plot_x, color);
|
|
}
|
|
plot_x++;
|
|
if(plot_y >= plot_x)
|
|
{
|
|
ML_horizontal_line(y+plot_x, x-plot_y, x+plot_y, color);
|
|
ML_horizontal_line(y-plot_x, x-plot_y, x+plot_y, color);
|
|
}
|
|
}
|
|
}
|