Witam posiadam problem z wypełnianiem okręgu, program się kompiluje ale niestety wypełnia jeden pixel, czy ktoś byłby mi w stanie wytłumaczyć dlaczego tak się dzieje ?
#include <iostream>
#include <allegro.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cmath>
using namespace std;
void circlec(int x, int y, int r){
int x1, y1;
for(double i = 0; i <= M_PI_4; i += 1.0 / (2 * r)){
x1 = r * cos(i);
y1 = r * sin(i);
putpixel(screen, x + x1, y + y1, makecol(255,0,0));
putpixel(screen, x + y1, y + x1, makecol(255,0,0));
putpixel(screen, x - y1, y + x1, makecol(255,0,0));
putpixel(screen, x - x1, y + y1, makecol(255,0,0));
putpixel(screen, x - x1, y - y1, makecol(255,0,0));
putpixel(screen, x - y1, y - x1, makecol(255,0,0));
putpixel(screen, x + y1, y - x1, makecol(255,0,0));
putpixel(screen, x + x1, y - y1, makecol(255,0,0));
}
}
void wypelnianie(int x, int y,int kw,int kk)
{
putpixel(screen,x,y,kw);
if(getpixel(screen,x,y)!=kw&&getpixel(screen,x,y)!=kk)
{
wypelnianie(x+1,y+1,kw,kk);
wypelnianie(x+1,y-1,kw,kk);
wypelnianie(x-1,y+1,kw,kk);
wypelnianie(x-1,y-1,kw,kk);
}
}
int main()
{
allegro_init();
if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 1800, 900, 0, 0) != 0)
{
allegro_message("Problem z ustawieniem trybu graficznego\n");
}
install_keyboard();
circlec(900,450,400);
wypelnianie(900,450,makecol(0,255,0),makecol(255,0,0));
readkey();
// kod programu
allegro_exit();
return 0;
}
END_OF_MAIN();