Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Computer Graphics

Introduction
It is an art of drawing pictures, lines, charts etc. on
computer screen by using some programing
languages and software.
In computer graphics objects are presented as a
collection of discrete picture elements . User can
edit the graphic object (pixels) with keyboard, mouse
and touch sensitive panel on screen.

Graphics devices = input devices + display devices

Advantage of Computer Graphics


1. High quality graphics display on personal
computers
2. Provides tools to produce the pictures.
3. Produce animations
4. Using motion dynamic tools
5. User can make object stationary and viewer
moving around them
6. Using update dynamics, it is possible to change
the shape, color or other properties of the object.
Applications of computer graphics
1. GUI
2. Multimedia
3. Educational software
4. Architecture
5. Printing technology
6. Computer arts
7. Computer generated maps
8. Biology
9. Visualization
10. Entertainment
11. Presentation graphics
12. Games

Types of Computer Graphics


➢There are two major types of computer graphics:
1. Non interactive computer graphics (NICG)
2. Interactive computer graphics (ICG)
• NICG
are passive User does not have any kind of control
over image Image will work according to instructions
given in stored program
• Example; screen savers
• ICG
involve two way communication between users and
computers User have some control over the image
User can make changes by giving different
commands with input device.
• E.g. video game
Digital Clock using C
Introduction
In this section, we will learn how to draw a digital
clock using C. Before we start learning how to draw a
digital clock using C, be sure that you know the C
basics like data types, looping statements, etc.

In this C program, the digital clock will start with the


time 00:00:00. Then it will work like a digital clock
where it will show the time with hours, minutes, and
second

How Digital Clock works in C


To draw a digital clock with the current time, the C
library function localtime can be used. It uses the
time pointed by the timer to fill a structure with the
values that represent the corresponding local time.

Digital Clock Reference image


Input of Digital Clock
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>

struct time t;
void display(int,int,int);
void main()
{
int i=0,gd=DETECT,gm,hr,min,sec;
clrscr();
initgraph(&gd,&gm,"c:\\turboc3\\bgi");
setcolor(GREEN);
settextstyle(4,0,7);

while(!kbhit())
{
gettime(&t);
hr=t.ti_hour;
min=t.ti_min;
sec=t.ti_sec;
i++;
display(100,100,hr);
display(200,100,min);
display(300,100,sec);
sound(400);
delay(30);
nosound();
delay(930);
cleardevice();
}
getch();
}
void display(int x,int y,int num)
{

char str[3];
itoa(num,str,10);

settextstyle(4,0,7);

outtextxy(180,100,":");
outtextxy(280,100,":");
outtextxy(x,y,str);

rectangle(90,90,380,200);
rectangle(70,70,400,220);

outtextxy(90,250,"Digital Clock");
}
Output of Digital Clock

You might also like