CG copy Paste

 Brensam 


#include<graphics.h> 

#include<stdio.h> 

void main() 

int x,y,x1,y1,x2,y2,dx,dy,p; 

int i,gd=DETECT,gm; 

initgraph(&gd,&gm,"C:\\TURBOC3\\BGI"); 

prinƞ("\n\nEnter co-ordinates of first point:"); 

scanf("%d%d",&x1,&y1); 

prinƞ("\n\nEnter co-ordinates of second point:"); 

scanf("%d%d",&x2,&y2); 

dx=(x2-x1); 

dy=(y2-y1); 

p=2*(dy)-(dx); 

x=x1; 

y=y1; 

putpixel(x,y,WHITE); 

while(x<=x2) 

if(p<0) 

{

x=x+1; 

y=y; 

p=p+2*(dy);

else 

x=x+1; 

y=y+1; 

p=p+2*(dy-dx); 

putpixel(x,y,WHITE); 

getch(); 

closegraph(); 

}


Basic shapes in center

#include<stdio.h>
void main()
{
int gd=DETECT,gm,x,y;
initgraph(&gd,&gm,"C:\\TURBOC3\\BGI");
x=getmaxx();
y=getmaxy();
circle(x/2,y/2,15);
rectangle(275,204,363,273);
rectangle(x/2-20,y/2-20,x/2+20,y/2+20);
ellipse(x/2,y/2,0,360,40,30);
circle(x/2,y/2,60);
circle(x/2,y/2,70);
circle(x/2,y/2,80);
circle(x/2,y/2,90);
circle(x/2,y/2,100);
line(0,y/2,x,y/2);
line(x/2,0,x/2,y);
getch();
closegraph();
}


Smiling Face Animation

 
#include <dos.h>
#include <graphics.h>
#include <stdio.h>
 int main()
{
int gr = DETECT, gm;
initgraph(&gr, &gm, "C:\\Turboc3\\BGI");
setcolor(YELLOW);
circle(300, 100, 40);
seƞillstyle(SOLID_FILL, YELLOW);
floodfill(300, 100, YELLOW);
setcolor(BLACK);
seƞillstyle(SOLID_FILL, BLACK);
fillellipse(310, 85, 2, 6);
fillellipse(290, 85, 2, 6);
ellipse(300, 100, 205, 335, 20, 9);
ellipse(300, 100, 205, 335, 20, 10);
ellipse(300, 100, 205, 335, 20, 11);
getch();
closegraph();
return 0;
}

Comments