google.com, pub-4617457846989927, DIRECT, f08c47fec0942fa0 Learn to enjoy every minute of your life.Only I can change my life.: etc graphics using c program
Showing posts with label etc graphics using c program. Show all posts
Showing posts with label etc graphics using c program. Show all posts

Tuesday, May 24, 2016

Graphics using C

To write program for graphics using c you must have following:

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<graphics. lib>
/*graphics header file necessary in graphics c program*/
main()
{
int gd = DETECT, gm;
/*initialization of graphics drivers*/
--------------------------
initgraph();
/*change the programs into graphics mode */

//other graphics functions

closegraph();
/*close the graphics*/
}

Following are some important terminology of graphics
1)Header File:
To perform program using graphs we have to first add the header file as
#include<graphics.h>
#include<graphics. lib>
It includes all graphics function definition.

2) Opening the graphics mode
Normally when any C program is work with any stream it is in by default text mode. Too convert text mode into graphics mode we can initializes the graphics program by using initgraph().
The meaning of initgraph is initialization of graph.
These function take 3 arguments which are as follows
i. graphics driver
ii. graphics mode
iii. path of BGI
Syntax:
initgraph(&gd,&gm,"C:\\TC\BGI");
where gd is predefine macro which is initialized by DETECT and gm is graphics mode and remaining is the path of BGI which is place in double quotation mark.

3) closegraph ()
The graphics mode can be exited by using closegraph() function.

Graphics program for draw a line
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<graphics. lib>
main()
{
int gd = DETECT, gm,x,y;
initgraph(&gd,&gm,"C:\\TC\BGI");
line(100,200,300,200);
getch();
closegraph();
}

Graphics program to draw a circle
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<graphics. lib>
main()
{
int gd = DETECT, gm,;
clrscr();
initgraph(&gd,&gm,"C:\\TC\BGI");
circle(200,100,100);
getch();
closegraph();
}

Graphics program to draw a ellipse
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<graphics. lib>
main()
{
int gd = DETECT, gm,;
clrscr();
initgraph(&gd,&gm,"C:\\TC\BGI");
ellipse(200,100,0,360,200,100);
getch();
closegraph();
}

Graphics program to draw an arc
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<graphics. lib>
main()
{
int gd = DETECT, gm,;
clrscr();
initgraph(&gd,&gm,"C:\\TC\BGI");
arc(200,100,0,90,100);
getch();
closegraph();
}

Graphics program to draw a rectangle
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<graphics. lib>
main()
{
int gd = DETECT, gm,;
clrscr();
initgraph(&gd,&gm,"C:\\TC\BGI");
rectangle(100,100,200,200);
getch();
closegraph();
}

Graphics program to draw a 7 sided polygon
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<graphics. lib>
main()
{
int gd = DETECT, gm,;
//total six coordinates
int points [] = {200,100,300,100,400,200,300,300,200,300,100,200,200,100};
clrscr();
initgraph(&gd,&gm,"C:\\TC\BGI");
drawpoly(7,points);
//here 7 denotes total sides
getch();
closegraph();
}

अच्छे विचार करे विचार

  पहचान की नुमाईश, जरा कम करें... जहाँ भी "मैं" लिखा है, उसे "हम" करें... हमारी "इच्छाओं" से ज़्यादा "सुन...