Académique Documents
Professionnel Documents
Culture Documents
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
void filler(int,int);
void fill(int,int);
void main()
rectangle(100,100,200,200);
rectangle(150,150,300,300);
filler(101,101);
fill(100,101);
getch();
closegraph();
if(getpixel(x,y)==0)
putpixel(x,y, RED);
filler(++x,y);
x=x-1;
filler(x,y+1);
filler(x,y-1);
if(getpixel(x,y)==0)
fill(--x,y);
x=x+1;
fill(x,y+1);
fill(x,y-1);
}}
Output:-
Program for Flood filling Algorithm:-
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
void filler(int,int);
void fill(int,int);
void main()
setcolor(BLUE);
rectangle(100,100,200,200);
rectangle(150,150,300,300);
filler(101,101);
fill(100,101);
getch();
closegraph();
if(getpixel(x,y)==0)
putpixel(x,y, RED);
filler(++x,y);
x=x-1;
filler(x,y+1);
filler(x,y-1);
if(getpixel(x,y)==0)
fill(--x,y);
x=x+1;
fill(x,y+1);
fill(x,y-1);
}}
Output:-
Program for Ellipse Algorithm:-
#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<graphics.h>
void main()
scanf("%f", &rx);
scanf("%f", &ry);
getch();
float x = 0, y = ry, p;
float px = 0, py = 2 * rxSq * y;
x++;
px = px + 2 * rySq;
if (p < 0)
p = p + rySq + px;
else
y--;
py = py - 2 * rxSq;
p = p + rySq + px - py;
while (y > 0)
y--;
py = py - 2 * rxSq;
if (p > 0)
p = p + rxSq - py;
else
x++;
px = px + 2 * rySq;
p = p + rxSq - py + px;
}
drawEllipse(xc, yc, x, y);