Proggramming Tutorials & Web Development Technologies - Tutorials for PHP,Laravel,Codeigniter,Yii,Bootstrap,Ajax,JQuery
Thursday, 6 March 2014
Tuesday, 4 March 2014
Draw Arc Using C
#include<conio.h>
#include<graphics.h>
#include<stdio.h>
#include<dos.h>
void main()
{
int gd=DETECT,gm=0;
initgraph(&gd,&gm,"c:\\tc\\bgi");
arc(110, 110, 0, 145, 55);
/*
arc(a,b,c,d,e);
a= x
b=y
c=start angle
d= end angle
e=radius of arc.
*/
getch();
closegraph();
}
#include<graphics.h>
#include<stdio.h>
#include<dos.h>
void main()
{
int gd=DETECT,gm=0;
initgraph(&gd,&gm,"c:\\tc\\bgi");
arc(110, 110, 0, 145, 55);
/*
arc(a,b,c,d,e);
a= x
b=y
c=start angle
d= end angle
e=radius of arc.
*/
getch();
closegraph();
}
Draw Rectangle Using C
#include<conio.h>
#include<graphics.h>
#include<stdio.h>
void main()
{
int gd=DETECT,gm=0;
initgraph(&gd,&gm,"c:\\tc\\bgi");
cleardevice();
int midx,midy,x,y;
x=getmaxx();
y=getmaxy();
midx=x/2;
midy=y/2;
rectangle(midx-110,midy-110,midx+110,midy+110);
getch();
closegraph();
}
#include<graphics.h>
#include<stdio.h>
void main()
{
int gd=DETECT,gm=0;
initgraph(&gd,&gm,"c:\\tc\\bgi");
cleardevice();
int midx,midy,x,y;
x=getmaxx();
y=getmaxy();
midx=x/2;
midy=y/2;
rectangle(midx-110,midy-110,midx+110,midy+110);
getch();
closegraph();
}
Draw Circle Using C
#include<conio.h>
#include<graphics.h>
#include<stdio.h>
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc\\bgi");
cleardevice();
gm=0;
circle(250,250,100);
/* circle(a,b,c);
a=X axis element
b=Y axis element
c=radius
*/
getch();
closegraph();
}
#include<graphics.h>
#include<stdio.h>
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc\\bgi");
cleardevice();
gm=0;
circle(250,250,100);
/* circle(a,b,c);
a=X axis element
b=Y axis element
c=radius
*/
getch();
closegraph();
}
Horizontal Line And Vertical Line of Center Of Screen Using C
#include<conio.h>
#include<graphics.h>
#include<stdio.h>
void main()
{
int gd=DETECT,gm,maxx,maxy,midx,midy;
initgraph(&gd,&gm,"c:\\tc\\bgi");
cleardevice();
maxx=getmaxx();
maxy=getmaxy();
midx=maxx/2;
midy=maxy/2;
line(0,midy,midx,maxy);
line(midx,0,midx,maxy);
getch();
closegraph();
}
////////////////////////////OUTPUT//////////////////////////////
#include<graphics.h>
#include<stdio.h>
void main()
{
int gd=DETECT,gm,maxx,maxy,midx,midy;
initgraph(&gd,&gm,"c:\\tc\\bgi");
cleardevice();
maxx=getmaxx();
maxy=getmaxy();
midx=maxx/2;
midy=maxy/2;
line(0,midy,midx,maxy);
line(midx,0,midx,maxy);
getch();
closegraph();
}
////////////////////////////OUTPUT//////////////////////////////
Midpoint Circle Drawing Algorithm Using C
#include<conio.h>
#include<graphics.h>
#include<stdio.h>
#include<dos.h>
void main()
{
int gd=DETECT,gm,xc,yc,r,x,y,p;
initgraph(&gd,&gm,"c:\\tc\\bgi");
cleardevice();
printf("Enter xc and yc:");
scanf("%d%d",&xc,&yc);
printf("Enter radius:");
scanf("%d",&r);
x=0;
y=r;
p=1.25-r;
do
{
putpixel(xc+x,yc+y,1);
putpixel(xc+y,yc+x,2);
putpixel(xc-x,yc+y,1);
putpixel(xc+y,yc-x,2);
putpixel(xc-y,yc-x,1);
putpixel(xc-x,yc-y,2);
putpixel(xc+x,yc-y,1);
putpixel(xc-y,yc+x,2);
if(p<0)
{
p=p+(2*x)+1;
}
else
{
p=p+(2*x)+1-(2*y);
y=y-1;
}
x=x+1;
}
while(x<y)
putpixel(xc+x,yc+y,2);
getch();
closegraph();
}
#include<graphics.h>
#include<stdio.h>
#include<dos.h>
void main()
{
int gd=DETECT,gm,xc,yc,r,x,y,p;
initgraph(&gd,&gm,"c:\\tc\\bgi");
cleardevice();
printf("Enter xc and yc:");
scanf("%d%d",&xc,&yc);
printf("Enter radius:");
scanf("%d",&r);
x=0;
y=r;
p=1.25-r;
do
{
putpixel(xc+x,yc+y,1);
putpixel(xc+y,yc+x,2);
putpixel(xc-x,yc+y,1);
putpixel(xc+y,yc-x,2);
putpixel(xc-y,yc-x,1);
putpixel(xc-x,yc-y,2);
putpixel(xc+x,yc-y,1);
putpixel(xc-y,yc+x,2);
if(p<0)
{
p=p+(2*x)+1;
}
else
{
p=p+(2*x)+1-(2*y);
y=y-1;
}
x=x+1;
}
while(x<y)
getch();
closegraph();
}
Bresenham Circle Drawing Algorithm Using C
#include<conio.h>
#include<graphics.h>
#include<stdio.h>
#include<dos.h>
void main()
{
int gd=DETECT,gm,xc,yc,r,x,y,p;
initgraph(&gd,&gm,"c:\\tc\\bgi");
cleardevice();
printf("Enter xc and yc:");
scanf("%d%d",&xc,&yc);
printf("Enter radius:");
scanf("%d",&r);
x=0;
y=r;
p=3-2*r;
do
{
delay(25);
putpixel(xc+x,yc+y,1);
putpixel(xc+y,yc+x,2);
putpixel(xc-x,yc+y,1);
putpixel(xc+y,yc-x,2);
putpixel(xc-y,yc-x,1);
putpixel(xc-x,yc-y,2);
putpixel(xc+x,yc-y,1);
putpixel(xc-y,yc+x,2);
if(p<0) {
p=p+4*x+6;
}
else
{
p=p+4*(x-y)+10;
y=y-1;
}
x=x+1;
}
while(x<y)
putpixel(xc+x,yc+y,2);
getch();
closegraph();
}
#include<graphics.h>
#include<stdio.h>
#include<dos.h>
void main()
{
int gd=DETECT,gm,xc,yc,r,x,y,p;
initgraph(&gd,&gm,"c:\\tc\\bgi");
cleardevice();
printf("Enter xc and yc:");
scanf("%d%d",&xc,&yc);
printf("Enter radius:");
scanf("%d",&r);
x=0;
y=r;
p=3-2*r;
do
{
delay(25);
putpixel(xc+x,yc+y,1);
putpixel(xc+y,yc+x,2);
putpixel(xc-x,yc+y,1);
putpixel(xc+y,yc-x,2);
putpixel(xc-y,yc-x,1);
putpixel(xc-x,yc-y,2);
putpixel(xc+x,yc-y,1);
putpixel(xc-y,yc+x,2);
if(p<0) {
p=p+4*x+6;
}
else
{
p=p+4*(x-y)+10;
y=y-1;
}
x=x+1;
}
while(x<y)
getch();
closegraph();
}
Subscribe to:
Posts (Atom)