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.
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
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;
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);
#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(); }