CGR 1

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Subject: Computer Graphics (22318) Omkar Dorugade

Practical no 1
Aim: Program to draw basic graphics objects

Course Outcome: Manipulate visual and geometric properties of images.

Practical Outcome: Write program to draw following graphics objects using built-in “C” functions

i. Pixel
ii. Lines
iii. Circles
iv. Rectangle

Theory: Output primitives: the primitives are the simple geometric function that are used to generate
various computer graphic object required by the user. Some most basic output primitive is point-
position (pixel), a straight line, circle, rectangle and ellipse. 

Computer Graphics Mode

Text Mode Graphics Mode

Text Mode: Screen is divided into character position. Screen is mapped as number of rows and columns.

Text Mode function:  

Putch( ): Displays single character at cursor position.  

Clrscr( ): Clears entire screen.  

Gotoxy( ): Position cursor to specifies location on screen.  

Textcolor( ): Apply color to text.  

Graphics Mode: Screen is divide into pixels. while working in c programming language, default
output mode is text mode. To draw graphics objects on screen display mode must be change
from text mode to graphic mode. To change from text mode initgraph(int *graphdriver, int graph
mode, char *pathtodriver);
Subject: Computer Graphics (22318) Omkar Dorugade
Practical no 1
Algorithm:
Step 1. Start  

Step 2. Declare and detect graphics drive  

Step 3. Declare variables  

Step 4. Initialize graphics mode  

Step 5. Accept choice of object to be known  

Step 6. Select the proper function to be the respect object  

Step 7. If(choice == pixel, use putpixel (int x, int y, intcolor)  

Step 8. If (choice == liner use function line (int x,int y,int x, int y)  

Step 9. If(choice == circle,use circle (int x ,int y, int radius)  

Step 10 . If(choice==rectangle, use rectangle(int left, int too, int right, int(bottom)

Step 11. If(choice==elipse, use elipse(int x, int y, strangle, end anfle, x radius, y radius)

Step 12. Stop

Flow Chart:

Start

Initialize graphics mode

Accept choice of object to be drawn

Use appropriate function to draw the object

Stop
Subject: Computer Graphics (22318) Omkar Dorugade
Practical no 1
C Program Code:

#include<stdio.h>  

#include<conio.h>  

#include<graphics.h>  

Void main ( )  

{  

 Int gd=DETECT,gm;  

 Initgraph(&gd,&gm,”c:\\TURBO\\BGI”);   Putpixel(50,50,RED);  

 Outtextxy(55,55,”PIXEL”);  

 Line(100,70,200,100);  

 Outttextxy(200,110,”line” );  

 Circle(230,50,50);  

 Outextxy((290,120,”circle”);d=   Rectangle(300,40,400,100);  

 Outtextxy(420,120,”pixel”);  

 Ellipse(450,50,0,360,100,175);   Outtextxy(450,200,”ellipse”);   Getch( );  

***********************************Output*************************************
Subject: Computer Graphics (22318) Omkar Dorugade
Practical no 1

You might also like