Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
5Activity
0 of .
Results for:
No results containing your search query
P. 1
Graphics Lab BCA35L

Graphics Lab BCA35L

Ratings: (0)|Views: 121 |Likes:
Published by api-3732063

More info:

Published by: api-3732063 on Oct 20, 2008
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

03/18/2014

pdf

text

original

1)/* Program to initialize the graph and draw a line * /
#include<graphics.h>
#include<conio.h>
void main()
{int gd =DETECT: /*Detect the graph driver dynamically*/

int gm;
/*for graph mode*/
initgraph (&gd,&gm,\u2019\u2019\u2019); /* graph driver, graph mode and

path has to be passed as parameters. The empty path is specified means the path will be taken dynamically after searching in the computer. Otherwise we need to spcify the path where bgi directory is stored in the computer */

line(10,10,200,200);
/* this function draws a line from
starting co-ordinates(10,10) to the target co-ordinates (200,200). These

co-ordintes are specified in terms of pixels */
getch();
closegraph();

/* close the graph mode */
}
2)

/* program to draw a rectangle , lines as its diagonals and a circle */
#include<graphics.h>
#include<conio.h>
void main()
{int gd=DETECT;

int gm;
initgraph(&gd,&gm,\u201d\u201d);
rectangle(10,10,200,200);

/* draws a rectangle */
line(10,10,200,200);
/* draw a line on the main diagonal*/
line(10,200,200, 10);
/* draws a line on off diagonal */
circle(105,105,95);

/* draws a circle taking (105,105) as center co-ordinates and 95 as radius all the dimensions are in pixels */

getch();
closegraph();
/*closes the graph mode */
}
3) /* program to draw a circle and ellipses */

#include<graphics.h>
#include<conio.h>
void main()
{int gd=DETECT;

int gm;
Initgraph (&gd,&gm,\u201d\u201d);
Circle (getmaxx ()/2,getmaxy ()/2,100);

/*draws
a
circle

taking
midpoint of the screen as center co-ordinates and
100 as radius */

setcolor(2); /*sets the drawing color as green */
ellipse(getmaxx()/2,0,360,80,50);
/* draws an ellipse taking center of the screen as its center , 0 as

starting angle and 360 as ending angle and 80 pixel as Y radius */
setcolor(4); /*sets the drawing color as red */
ellipse(getmaxx()/2, getmaxy()/2,90,270,50, 80);
/*draws half the ellipse starting from 90 angle and

ending
at

27o
angle with 50 pixels as X-radius and 80 pixels as Y-radius in red color */
getch();
closegraph();

/* closes the graph mode */
}4) /* program to demonstrate put pixel */

# include<graphics.h>
# include<conio.h>
# include <stdlib.h>
# include<dos.h>

void main()
{int gm, gd=DETECT,I;
initgraph(&gd, &gm,\u2019\u2019\u2019\u2019);

while(!kbhit())/* until pressing any key this loop continues */
{putpixel(rand()%getmaxx(), rand() % getmaxy(), rand()%16);
/*x and y co-ordinates and the color are taken randomly*/
delay(2);
/* just to draw the pixels slowly*/
}getch ();
closegraph();
/* closes the graph mode */
}
5)
/* Program to demonstrate rectangles using putpixel and filling them

with different fill effects */
# Include <graphics.h>
# Include <conio.h>
# include <stdlib.h>
# include <dos.h>

void main()
{int gm,gd= DETECT;
int x1,x2,y1,y2,c,I;

initgraph(&gd,&gm,\u2019\u2019\u2019\u2019);
while(!kbhit()) /* until pressing any key this loop continues */
{
/* To draw rectangle co-ordinatinates are taken randomly */
x1=rand()%getmaxx();
x2=rand()%getmaxx();
y1=rand()%getmaxy();
y2=rand()%getmaxy();

if (x1>x2)
{c=x1;

/* exchange of x1 and x2 when x1 is >x2 */
x1=x2;
x2=c;
}if(y1>y2)

{c=y1;
/* exchange of y1 and y2 when y1 is > y2 */
y1=y2;

Activity (5)

You've already reviewed this. Edit your review.
1 hundred reads
shruti_s liked this
jk00786 liked this
syriluit liked this
raj2@raj liked this

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->