Anda di halaman 1dari 11

PROJECT OF COMPUTER GRAPHICS

Name of the project:- DESIGN A SCREEN SAVER


IN CWITH A SEA BEACH SCENARIO

SUBMITTED BY:SUBMITTED TO:AMANDEEP SINGH


Deepika Sukhija

(10804926) TEJINDER KAUR (10804410)

Introduction
Computer Graphics : It involves display manipulation and storage of pictures and experimental data for proper visualization using a computer. Typically graphics system comprises of the host computers with support of
fast processor, large memory, frame buffer display devices, input devices, output devices interface devices.

Typical Application Areas


GUI Plotting in business Office Automation Desktop Publishing Plotting in Science and Technology Web/Commercial/Business publishing and advertisements CAD/CAM Design(VLSI, Construction, Circuits) Scientific visualization Entertainment Simulation and Simulation Study Cartography Multimedia Virtual reality Process monitoring Digital Image processing Education and Training

CODING OF OUR GIVEN PROJECT


#include<iostream.h> #include<conio.h> #include<graphics.h> #include<dos.h> int i; void taj() { setlinestyle(3,1,1); setcolor(BLUE); for(i=3;i<280;i=i+3) { delay(20); line(3,670-i,660,670-i); } } void taj1() { for(i=3;i<122;i=i+3) { delay(50);

line(3,391+i,660,391+i); } } void floodfill(int x,int y,int fillColor, int oldc) { if(getpixel(x,y)==oldc) { putpixel(x,y,fillColor); floodfill(x+1,y,fillColor,oldc); floodfill(x-1,y,fillColor,oldc); floodfill(x,y+1,fillColor,oldc); floodfill(x,y-1,fillColor,oldc); }

void main() { char ch; int i,j,n; int gm=0,gd=DETECT; initgraph(&gm,&gd,"C:\\TC\\BGI"); taj(); ch=getche(); if(ch==13) { while(!kbhit()) { delay(10); taj();

delay(10); taj1(); cleardevice(); line(0,100,50,60); line(50,60,100,100); line(100,100,150,50); line(150,50,200,100); line(200,100,250,50); line(250,50,300,100); line(300,100,350,50); line(350,50,400,100); line(400,100,450,50); line(450,50,500,100); line(500,100,550,50); line(550,50,600,100);

// for Hills

float radius=15; int x=200; int y=50; circle(x,y,radius); floodfill(x,y,4,getpixel(x,y)); line(50,300,250,300); line(250,300,250,120); line(250,120,50,120); line(50,120,50,300); line(200,300,200,120); house line(200,120,225,90); line(225,90,250,120); line(50,120,75,90);

// for Sun

// for

line(75,90,225,90); line(210,300,210,250); line(210,250,240,250); line(240,250,240,300); } } getch(); }

ABOUT PROJECT
This above coding is for my project named sea beach scenario. The whole coding of this project is in c language. The important that are used in this project are:1)putpixel 2)getpixel 3)floodfill 4)line 5)circle 6)delay Q) What is floodfill? Ans: Flood fill, also called seed fill, is an algorithm that
determines the area connected to a given node in a multi-dimensional array. It is used in the "bucket" fill tool of paint programs to determine which parts of a bitmap to fill with color, and in games such as Go and Minesweeper for determining which pieces are cleared.

When applied on an image to fill a particular bounded area with color, it is also known as boundary fill. The flood fill algorithm takes three parameters: a start node, a target color, and a replacement color. The algorithm looks for all nodes in the array which are connected to the start node by a path of the target color, and changes them to the replacement color. There are many ways in which the flood-fill algorithm can be structured, but they all make use of a queue or stack data structure, explicitly or implicitly. Depending on whether we consider nodes touching at the corners connected or not, we have two variations, Eight-way and Four-way, respectively. Syntax:- Flood-fill (node, target-color, replacementcolor)

Q)What is putpixel function? Ans: putpixel function plots a pixel at location (x, y) of
specified color. Declaration :- void putpixel(int x, int y, int color); For example if we want to draw a GREEN color pixel at (35, 45) then we will write putpixel(35, 35, GREEN); in our c program, putpixel function can be used to draw circles, lines and ellipses using various algorithms. #include<graphics.h> #include<conio.h> main() { int gd = DETECT, gm;

initgraph(&gd, &gm, "C:\\TC\\BGI"); putpixel(25, 25, RED); getch(); closegraph(); return 0; }

Q) What is getpixel function? Ans: getpixel function returns the color of pixel present
at location (x, y). Declaration :- int getpixel(int x, int y); For example:#include<graphics.h> #include<conio.h> main() { int gd = DETECT, gm, color; char array[50]; initgraph(&gd,&gm,"C:\\TC\\BGI"); color = getpixel(0, 0); sprintf(array,"color of pixel at (0,0) = %d",color); outtext(array);

getch(); closegraph(); return 0; }

Q) Why line function is used? Ans:


Syntax: line(x1,y1,x2,y2);
Parameter x1 y1 x2 y2 Explanation X Co-ordinate of First Point Y Co-ordinate of First Point X Co-ordinate of Second Point Y Co-ordinate of Second Point

#include<graphics.h> #include<stdio.h> int main(void) { int gdriver = DETECT,gmode; int x1=200, y1=200; int x2=300, y2=300; initgraph(&gdriver, &gmode, "c:\tc\bgi"); line(x1,y1,x2,y2);

closegraph(); }

Anda mungkin juga menyukai