Graphics Function

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 10

SANJIVANI K. B. P.

POLYTECHNIC, KOPARGAON
With NBA ACCREDIATED programs , Approved by AICTE, New Delhi,
Recognized by Govt. of Maharashtra, Affiliated to Maharashtra State Board of Technical Education, Mumbai,
ISO 9001:2015 Certified Institute

Department:- Infomation Technology Class:- SY CO

Name of Subject:- Computer Graphics MSBTE Subject Code:-


22318
Graphics Functions and Standards.
1.4.1 Graphics mode and Graphics mode function
• Graphics mode is a computer display mode that displays image using pixels.
• In graphics mode, the display screen is treated as an array of pixels. Programs
that run in graphics mode can display an unlimited variety of shapes and fonts.
Basic Graphics Mode functions:
1.initgraph( ):It is used to initialise graphics mode.
Syntax:initgraph(int driver, int mode, char path);
Where,
• driver: This argument specifies the graphics driver to be used and it
interfaces with display adapter, some of available drivers are CGA, EGA, VGA
etc.
Sanjivani K.B.P. Polytechnic, Kopargaon Department
of Computer Engg A. L. Deokate
Mode:
• Each graphic adapter can use several different possible graphics modes. The
mode argument is used to select particular mode. Following table shows different
possible modes for CGA, VGA, EGA etc
CGA-Computer Graphics Adapter
VGA-Video Graphics Adapter
EGA-Enhanced Graphics Adapter
path:
• It specifies path to graphics driver. Graphics drivers are files with
BGI(Borland Graphics Adapter)file extension supplies as part of Turbo C++. The
path name is string therefore it must be surrounded by quotes.
Sanjivani K.B.P. Polytechnic, Kopargaon Department
of Computer Engg A. L. Deokate
Example: initgraph(&gd, &gm, “c:\\tc\\bgi”);
int gm, gd= DETECT
Where, gd-specifies graphics driver
gm-specifies graphics mode
“c:\\tc\\bgi”-specifies paths of BGI files.
DETECT-is micro which automatically selects the driver.
2.closegraph( ):
It is used to close graphics mode.
Syntax: closegraph( );
Sanjivani K.B.P. Polytechnic, Kopargaon Department
of Computer Engg A. L. Deokate
Graphics Mode functions for Shape
• Computer graphics has many inbuilt commands, which can be
used either to draw a shape and /or for filling a colour in any
bounded shape.
1.lineto( ):
• This command draws a line on screen from current cursor
positions to the(x, y) positions mentioned in command.
Syntax-lineto(x, y);
Where, (x, y) are co-ordinates of end of line.

Sanjivani K.B.P. Polytechnic, Kopargaon Department


of Computer Engg A. L. Deokate
2.line( ):
• This command draws a line on screen.
Syntax: line(x1,y1,x2,y2);
Where, (x1, y1) are co-ordinates of starting point of line and (x2,
y2) are co-ordinates of end point of line.
Example :-line(10, 10, 100, 100);
• It will draw a line from point (10, 10) to point (100, 100).

Sanjivani K.B.P. Polytechnic, Kopargaon Department


of Computer Engg A. L. Deokate
3. circle( ):
This command draws a circle on screen.
Syntax: circle(x, y, r);
Where, (x, y) are co-ordinates of centre of circle and r is radius of circle.
Example :-circle (50, 50, 10);
It draws a circle with centre 50, 50 and radius 10.

Sanjivani K.B.P. Polytechnic, Kopargaon Department


of Computer Engg A. L. Deokate
4.rectangle( ):
This command draws a rectangle on screen.
Syntax: rectangle(x1, y1, x2, y2);
Where,(x1, y1) are co-ordinates of top left corner point of rectangle
and (x2, y2) are co-ordinates of bottom right corner point of rectangle.
Example :-rectangle(10, 10, 100, 100);
It will draw a rectangle as a top left corner is(10,10) & bottom
right corner(100,100).

Sanjivani K.B.P. Polytechnic, Kopargaon Department


of Computer Engg A. L. Deokate
5. ellipse( ):
• It draws an ellipse on screen.
Syntax: ellipse(x, y, start, end , xrad, yrad);
Where,
x, y are co ordinates of centre point.
start, end-starting and ending angle of ellipse.
xrad, yrad: x-axis and y-axis radius respectively.
For full ellipse, the start and end should be 0 to 360 else it will draw an
arc on screen.
Example :-ellipse(100, 100, 0, 360, 20, 10);
Sanjivani K.B.P. Polytechnic, Kopargaon Department
of Computer Engg A. L. Deokate
6. drawpoly( ):
• It draws outline of polygon having specified number of sides.
Syntax: drawpoly(n, array);
Where, n is number of vertices of a polygon +1.
Array is integer array name which stores co-ordinates of vertices of a
polygon.
Example: To draw a triangle with drawpoly.
drawpoly(4, m);
where,m is array which stores co –ordinates of vertices of a triangle.
Sanjivani K.B.P. Polytechnic, Kopargaon Department
of Computer Engg A. L. Deokate

You might also like