0% found this document useful (0 votes)
25 views15 pages

Lecture 3

This document outlines functions for drawing various shapes and manipulating colors in a computer graphics lab. It describes how to draw ellipses, elliptical arcs, circular arcs, and filled ellipses using specific functions. It also explains how to set the drawing color and background color, get the current colors, and clear the screen using additional functions. Examples are provided with each function to demonstrate its proper syntax and use. The document serves as a tutorial for using these graphics functions in a computer graphics lab.

Uploaded by

rahul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views15 pages

Lecture 3

This document outlines functions for drawing various shapes and manipulating colors in a computer graphics lab. It describes how to draw ellipses, elliptical arcs, circular arcs, and filled ellipses using specific functions. It also explains how to set the drawing color and background color, get the current colors, and clear the screen using additional functions. Examples are provided with each function to demonstrate its proper syntax and use. The document serves as a tutorial for using these graphics functions in a computer graphics lab.

Uploaded by

rahul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

Computer Graphics Lab

Graphics In
C Lab
Outline
 Draw Ellipse

 Draw Elliptical Arc

 Draw Circular arc

 Draw Filled Ellipse

 Set Drawing Color

 Set Background Color

 Get Drawing Color

 Get Background Color

 Clear Device

Mrs. Aparna Shukla/ DMW Notes 11/29/20 2


23
Ellipse
 ellipse () functions is used to draw a Ellipse and Elliptical Arc.

Syntax-

void ellipse( int x, int y, int stangle, int endangle, int xrad, int yrad);

 x & y- specifies the coordinate of center the ellipse

 stangle - specifies the starting angle

 endangle - specifies the end angle

 xrad & yrad- specifies the X and Y Radius of the ellipse

Mrs. Aparna Shukla/ DMW Notes 11/29/20 3


23
Draw Ellipse
Example 1-

ellipse(100, 100, 0, 360, 50, 25); // Draw an ellipse

ellipse(100, 100, 90, 270, 50, 25); // Draw an


elliptical arc

Mrs. Aparna Shukla/ DMW Notes 11/29/20 4


23
Circular Arc
 arc () functions is used to draw a Ellipse and Elliptical Arc.

Syntax-

void arc( int x, int y, int stangle, int endangle, int rad);

 x & y- specifies the coordinate of center of the arc

 stangle - specifies the starting angle

 endangle - specifies the end angle

 rad - specifies the radius of the arc

Mrs. Aparna Shukla/ DMW Notes 11/29/20 5


23
Draw Circular Arc-Example
Example 1-

arc(100, 100, 0,180, 25); // Draw an circular arc

Mrs. Aparna Shukla/ DMW Notes 11/29/20 6


23
Fillellipse
 fillellipse () functions is used to draw a filled ellipse

Syntax-

void fillellipse( int x, int y, int xrad, int yrad);

 x & y- specifies the coordinate of center the ellipse

 xrad & yrad- specifies the X and Y Radius of the ellipse

Example 1-

fillellipse(100, 100, 50, 25);

Mrs. Aparna Shukla/ DMW Notes 11/29/20 7


23
Set Drawing Color

 Use function setcolor()

 setcolor()- used to change the current drawing color

Syntax-

void setcolor( int color);

 In C Graphics , total 16 colors are available.

 Each color is assigned a number. For example- Black =0, Red=4 etc.

 Default drawing color is WHITE

Mrs. Aparna Shukla/ DMW Notes 11/29/20 8


23
Set Drawing Color-example
Example 1-

circle(100, 100, 50); //Draw Circle in white color

setcolor(RED);

circle(300,300,50); //Draw Circle in Red color

Mrs. Aparna Shukla/ DMW Notes 11/29/20 9


23
Set Background Color
 Use function setbkcolor()

 setbkcolor()- used to change the current background color

Syntax-

void setbkcolor( int color);

 Default background color is BLACK

Example 1-

setbkcolor(RED);

circle(300,300,50); //Draw Circle in background Red


color
Mrs. Aparna Shukla/ DMW Notes 11/29/20 10
23
Get Current Drawing Color
 Use function getcolor()

 setbkcolor()- returns current drawing color

Syntax-

int getcolor( );

 It returns integer value

 If current drawing color is red, it will return 4.

Example 1-

int c;

c=getcolor();
Mrs. Aparna Shukla/ DMW Notes 11/29/20 11
23
Get Current Background Color
 Use function getbkcolor()

 getbkcolor()- returns current background color

Syntax-

int getbkcolor( );

 It returns integer value

Example 1-

int c;

c=getbkcolor();

Mrs. Aparna Shukla/ DMW Notes 11/29/20 12


23
Cleardevice
 Use function cleardevice()- used to clear all drawing from the screen yet drawn

Syntax-

cleardevice();

Mrs. Aparna Shukla/ DMW Notes 11/29/20 13


23
Next Topic

 Bar

 3dBar

 Filled Rectangle

Mrs. Aparna Shukla/ DMW Notes 11/29/20 14


23
THANKS

Mrs. Aparna Shukla/ DMW Notes 11/29/20 15


23

You might also like