CGR 1
CGR 1
CGR 1
Practical no 1
Aim: Program to draw basic graphics objects
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.
Text Mode: Screen is divided into character position. Screen is mapped as number of rows and columns.
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 8. If (choice == liner use function line (int x,int y,int x, int y)
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)
Flow Chart:
Start
Stop
Subject: Computer Graphics (22318) Omkar Dorugade
Practical no 1
C Program Code:
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
{
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”);
}
***********************************Output*************************************
Subject: Computer Graphics (22318) Omkar Dorugade
Practical no 1