Documente Academic
Documente Profesional
Documente Cultură
...................................
#include<graphics.h>
#include<conio.h>
int main()
initgraph(&gd,&gm,"C:\\TURBOC3\\BGI");
setcolor (WHITE);
rectangle(150,180,250,300);
rectangle(250,180,420,300);
rectangle(180,250,220,300);
line(200,100,150,180);
line(200,100,250,180);
line(200,100,370,100);
line(370,100,420,180);
setfillstyle(SOLID_FILL,BROWN);
floodfill(152,182,WHITE);
floodfill(252,182,WHITE);
setfillstyle(SLASH_FILL,BLUE);
floodfill(182,252,WHITE);
setfillstyle(HATCH_FILL,GREEN);
floodfill(200,105,WHITE);
floodfill(210,105,WHITE);
getch();
return 0;
}
Floodfill to fill a circle
..............................
#include<graphics.h>
#include<conio.h>
void main()
initgraph(&gd,&gm,"c:\\TURBOC3\\BGI");
circle(100,100,50);
setfillstyle(HATCH_FILL,RED);
floodfill(100,100,WHITE);
getch();
DDA
......................................
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
int gd=DETECT,gm,x=25,y=25,font=10;
initgraph(&gd,&gm,"c:\\turbocC3\\BGI");
for(font=0;font<=4;font++)
settextstyle(font,HORIZ_DIR,font+1);
setcolor(font+1);
outtextxy(x,y,"text with deffrent fronts");
y=y+25;
for(font=0;font<=2;font++)
settextstyle(font,VERT_DIR,font+2);
setcolor(font+1);
x=250;
y=100;
y=y+25;
getch();
closegraph();
____________________________
__________________________
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
int main()
int x,y,i,flag=0;
initgraph(&gdriver,&gmode,"C:\\TURBOC3\\BGI");
x=getmaxx()/2;
y=30;
while(!kbhit())
if(y>=getmaxy()-30||y<=30)
flag=!flag;
setcolor(RED);
setfillstyle(SOLID_FILL,RED);
circle(x,y,30);
floodfill(x,y,RED);
delay(50);
cleardevice();
if(flag)
y=y+5;
else
y=y-5;
closegraph();
return 0;
____________________________
__________________________
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
int main()
int x,y,i,flag=0;
initgraph(&gdriver,&gmode,"C:\\TURBOC3\\BGI");
x=30;
y=getmaxy()/2;
while(!kbhit())
if(x>=getmaxx()-30||x<=30)
flag=!flag;
setcolor(RED);
setfillstyle(SOLID_FILL,RED);
circle(x,y,30);
floodfill(x,y,RED);
delay(50);
cleardevice();
if(flag)
x=x+20;
else
x=x-20;
closegraph();
return 0;
}
___________________________
_____________________________
#include<stdio.h>
#include<graphics.h>
#include<dos.h>
int main()
int x,y,i;
initgraph(&gdriver,&gmode,"C:\\TURBOC3\\BGI");
x=getmaxx()/2;
y=getmaxy()/2;
for(i=30;i<200;i++)
delay(100);
setcolor(i/10);
arc(x,y,0,180,i-10);
return 0;
_____________________________________________
______________________________________________
#include<stdio.h>
#include<graphics.h>
#include<dos.h>
void rainbow()
int x,y,i;
initgraph(&gdriver,&gmode,"C:\\TURBOC3\\BGI");
x=getmaxx()/2;
y=getmaxy()/2;
for(i=30;i<200;i++)
delay(100);
setcolor(i/10);
arc(x,y,0,180,i-10);
int main()
rainbow();
return 0;
__________________________________
Cosine wave
_________________________________
#include<stdio.h>
#include <math.h>
#include<graphics.h>
#include <conio.h>
#include<dos.h>
int main()
int angle=0;
double x,y;
initgraph(&gdriver,&gmode,"C:\\TURBOC3\\BGI");
y= 50 * sin(angle* 3.141/180);
y= getmaxy()/2 - y;
putpixel(x, y ,15);
delay(100);
angle +=5;
getch();
return 0;
_______________________________
Sine wave
_______________________________
#include<conio.h>
#include<math.h>
#include<graphics.h>
#include<dos.h>
int main(){
int angle=0;
double x, y;
initgraph(&gd,&gm, "C:\\Turboc3\\BGI");
y=50*sin(angle*3.141/180);
y=getmaxy()/2-y;
putpixel(x,y,25);
delay(50);
angle+=25;
getch();
closegraph();
return 0;
_______________________________
_______________________________
#include<conio.h>
#include<graphics.h>
#include<dos.h>
#include<stdlib.h>
int main(){
int i, x, y;
initgraph(&gd,&gm, "C:\\Turboc3\\BGI");
while(!kbhit())
{
x=rand()%getmaxx();
y=rand()%getmaxy();
putpixel(x,y,15);
delay(500);
cleardevice();
getch();
closegraph();
return 0;
_______________________________
_______________________________
#include<conio.h>
#include<graphics.h>
#include<dos.h>
#include<stdlib.h>
int main(){
int i, x, y;
initgraph(&gd,&gm, "C:\\Turboc3\\BGI");
while(!kbhit())
{
x=rand()%getmaxx();
y=rand()%getmaxy();
putpixel(x,y,RED);
delay(500);
cleardevice();
getch();
closegraph();
return 0;
_______________________________
Digital clock
_______________________________
#include<conio.h>
#include<graphics.h>
#include<dos.h>
#include<time.h>
#include<string.h>
int main()
int midx,midy;
long current_time;
char timestr[256];
initgraph(&gd,&gm, "C:\\Turboc3\\BGI");
midx=getmaxx()/2;
midy=getmaxy()/2;
while(!kbhit())
cleardevice();
setcolor(WHITE);
setfillstyle(SOLID_FILL,WHITE);
current_time = time(NULL);
strcpy(timestr, ctime(¤t_time));
setcolor(RED);
settextjustify(CENTER_TEXT, CENTER_TEXT);
moveto(midx, midy);
outtext(timestr);
delay(1000);
getch();
closegraph();
return 0;