SlideShare ist ein Scribd-Unternehmen logo
1 von 37
PUNJAB COLLEGE OF
      TECHNICAL EDUCATION




PRACTICAL
   FILE                 BC-507

SUBMITTED BY:          SUBMITTED BY:
Ms.Richa Sharma         Neha Sharma
Assistant Professor     (94972346352)
P.C.T.E.              BCA-5th Sem




                                        Page | 0
Index

S.No Contents                      Page no. Remarks
1.   Introduction to graphics      2
2.   Applications of graphics      3-5
3.   Graphics In-built functions   6-15
4.   Programs of Algorithm      16-26
     a) Direct method of line
     b) DDA Algorithm
     c) Bresenham algorithm
     d) Direct method of Circle
     e) Polar Circle
     f) Bresenham Circle
     g) Midpoint Circle
     h) Direct Ellipse
     i) Polar Ellipse
     j) Mid point Ellipse
5.   Static Application
6.   Ist dynamic Application
7.   IInd Dynamic Application




                                              Page | 1
1. Introduction To Graphics


Computer graphics are graphics created using computers and, more generally, the
representation and manipulation of image data by a computer with help from specialized
software and hardware.

The development of computer graphics has made computers easier to interact with, and
better for understanding and interpreting many types of data. Developments in computer
graphics have had a profound impact on many types of media and have revolutionized
animation, movies and the video game industry.

the term computer graphics refers to several different things:

   the representation and manipulation of image data by a computer
   the various technologies used to create and manipulate images
   the images so produced, and
   the sub-field of computer science which studies methods for digitally synthesizing and
   manipulating visual content




                                                                                 Page | 2
2. Application of Graphics
Computer graphics may be used in the following areas:

       COMPUTER AIDED DESIGN
       PRESENTATION GRAPHICS
       COMPUTER ART
       ENTERTAINMENT
       EDUCATION AND TRAINING
       VISUALIZATION
       IMAGE PROCESSING
       GRAPHICAL USER INTERFACE
       VIDEO GAMES

Computers have become a powerful tool for the rapid and economical production of
pictures. Advances in computer technology have made interactive computer graphics a
practical tool. Today, computer graphics is used in the areas as science, engineering,
medicine, business, industry, government, art, entertainment, advertising, education, and
training.


COMPUTER AIDED DESIGN
       A major use of computer graphics is in design processes, particularly for
engineering and architectural systems. For some design applications; objects are first
displayed in a wireframe outline form that shows the overall sham and internal features of
objects.

       Software packages for CAD applications typically provide the designer with a multi-
window environment. Each window can show enlarged sections or different views of
objects. Standard shapes for electrical, electronic, and logic circuits are often supplied by
the design package. The connections between the components have been mad
automatically.

       Animations are often used in CAD applications.
       Real-time animations using wire frame displays are useful for testing performance
       of a vehicle.
       Wire frame models allow the designer to see the interior parts of the vehicle during
       motion.
       When object designs are complete, realistic lighting models and surface rendering
       are applied.
       Manufacturing process of object can also be controlled through CAD.

                                                                                   Page | 3
Interactive graphics methods are used to layout the buildings.
     Three-dimensional interior layouts and lighting also provided.
     With virtual-reality systems, the designers can go for a simulated walk inside the
     building.


PRESENTATION GRAPHICS
    It is used to produce illustrations for reports or to generate slide for with
     projections.
    Examples of presentation graphics are bar charts, line graphs, surface graphs, pie
     charts and displays showing relationships between parameters.
    3-D graphics can provide more attraction to the presentation.


COMPUTER ART
    Computer graphics methods are widely used in both fine are and commercial art
     applications.
    The artist uses a combination of 3D modeling packages, texture mapping, drawing
     programs and CAD software.
    Pen plotter with specially designed software can create “automatic art”.
    “Mathematical Art” can be produced using mathematical functions, fractal
     procedures.
    These methods are also applied in commercial art.
    Photorealistic techniques are used to render images of a product.
    Animations are also used frequently in advertising, and television commercials are
     produced frame by frame. Film animations require 24 frames for each second in the
     animation sequence.
    A common graphics method employed in many commercials is morphing, where
     one object is transformed into another.


ENTERTAINMENT
    CG methods are now commonly used in making motion pictures, music videos and
     television shows.
    Many TV series regularly employ computer graphics method.
    Graphics objects can be combined with a live action.


EDUCATION AND TRAINING
    Computer-generated models of physical, financial and economic systems are often
     used as educational aids.

                                                                             Page | 4
   For some training applications, special systems are designed.
    Eg. Training of ship captains, aircraft pilots etc.,
    Some simulators have no video screens, but most simulators provide graphics
     screen for visual operation. Some of them provide only the control panel.


VISUALIZATION
    The numerical and scientific data are converted to a visual form for analysis and to
     study the behavior called visualization.
    Producing graphical representation for scientific data sets are calls scientific
     visualization.
    And business visualization is used to represent the data sets related to commerce
     and industry.
    The visualization can be either 2D or 3D.


IMAGE PROCESSING
    Computer graphics is used to create a picture.
    Image processing applies techniques to modify or interpret existing pictures.
    To apply image processing methods, the image must be digitized first.
    Medical applications also make extensive use of image processing techniques for
     picture enhancements, simulations of operations, etc.


GRAPHICAL USER INTERFACE
    Nowadays software packages provide graphics user interface (GUI) for the user to
     work easily.
    A major component in GUI is a window.
    Multiple windows can be opened at a time.
    To activate any one of the window, the user needs just to check on that window.
    Menus and icons are used for fast selection of processing operations.
    Icons are used as shortcut to perform functions. The advantages of icons are which
     takes less screen space.
    And some other interfaces like text box, buttons, and list are also used.




                                                                               Page | 5
3. Inbuilt Functions:


1. Arc
Arc draws a circular arc in the current drawing color.

Declaration:

Void arc(int x, int y , int Stangle, int endangle , int radius )

ARGUMENT                     What it is Does

(x,y)                        Center point of arc

Stangle                     Start angle in degrees

Endangle                     End angle in degrees

Radius                       Radius of arc

The arc travels from Stangle to Endangle

If Stangle =0 and Endangle = 360 , the call to arc draws a complete circle




2. Initgraph
Initializes the graphic system

Decalaration:

Void far initgraph(int far * graphdriver);

Int far * graphmode , char far *pathdriver);

Remarks:

To start the graphics system , you must first call the initgraph

Initgraph initializes the graphics system by loading a graphics the driver from disk (or
validating a registered driver ) then putting the system into graphics mode .

                                                                                   Page | 6
Initgraph also resets all the graphics settings (color ,palette ,current position , viewport
,etc) to their defaults , then resets graphresult to 0 .

Argument           What it is  does

*graphdriver         Integer that specifies the graphic driver to be used . you can give

                   graphdriver a value using a constant of the graphics_drivers
enumeration

                   type .

*graphmode         Integer that specifies the initial graphics mode .(unless *graphdriver

                   =DETECT).

If *graphdriver =DETECT , initgraph sets *graphmode to the highest resolution available
for the detected driver . You can give the *graphmode a value using a constant of the
graphics_modes enumeration type .

*graphdriver and *graphmode must be set to the valid graphics _drivers and
graphics_mode values or you will get unpredictable results . ( the exception is graphdriver
= DETECT).

After a call to the initgraph , *graphdriver is set to the current graphics driver , and
*graphmode is set to the current graphics mode .




3. closegraph
Shuts down the graphics system

Declaration :

void far closegraph( void );

Remarks :

Closegraph deallocates all memory allocated by the graphics system . It then restores the
screen to the mode it was in before you called initgraph .

( the graphics system deallocates memory such as the drivers , fonts , and an internal
buffer , through a call to the _graphfreemem)


                                                                                       Page | 7
Return Value : None




4.line
Line draws a line between the two specified points

Declaration :

Void far line ( int x1, int y1 , int x2 , int y2 );

Remarks :

Line draws a line from the ( x1, y1 ) to ( x2,y2 ) using the current color , line style nad thick
ness . it does not the update the current position (cp).




5. setcolor
Setcolor sets the current drawing color

Declaration:

Void far setcolor( int color)

Remarks :

Setcolor sets the current drawing color to color , which can range from 0 to getmaxcolor

To select a drawing color is the value that pixels are set to the when the program draws
lines etc.

Return value :

Setcolor does not return




6.setbkcolor

                                                                                       Page | 8
Setbkcolor sets the current background the color using the palette

Declaration :

Void far setbkcolor( int color );

Remarks :

Setbkcolor sets the background to the color specified by color

Color :

color is either a number or symbolic name specifying the color to set

For example , if you want to set the background color to blue , you can call

setbkcolor (BLUE) /* or */ setbkcolor(1)

On CGA and EGA systems , setbkcolor changes the background color by changing the first
entry in the palette.

Return:

Setbkcolor does not return




7.Ellipse
Ellipse draws an elliptical arc

Declaration :

Void far ellipse ( int x, int y , int stangle , int endangle , int xradius , int yradius ) ;

Remarks :

Ellipse draws an elliptical arc in the current drawing color .

Argument                  What it is

( x,y)                     Center of ellipse

Xradius                    Horizontal axis

Yradius                    Vertical axis

                                                                                               Page | 9
Stangle                    starting angle

Endangle                   ending angle

The ellipse travels from stangle to endangle .

If stangle = 0 and endangle = 360 , the call to the ellipse draws a complete ellipse .

The linestyle parameter does not affect the arcs , circles , ellipse or pie slices . only the

thickness parameter is used .

Return value :

None




8.Flood fill :
Flood fills a bounded region

Declaration :

void far floodfill( int x, int y , int border );

Remarks :

Floodfill fills an enclosed area on bitmap devices .

The area bounded by the color border is flooded with the current fill pattern and fill color .

(x,y) is the “seed point ”.

     If the seed is within an enclosed area , the inside will be filled .
     If the seed is outside the enclosed area, the exterior will be filled .

Use fillpoly instead of floodfill whenever possible so you can maintain code compatibility
with future versions .




9.Outtextxy

                                                                                       Page | 10
Outtextxy displays a string at the specified location ( graphics mode )

Declaration :

Void far outtextxy (int x , int y , char far * textstring );

Remarks :

Outtextxy displays a text string using the current justification settings and the current font
, direction and size .

Outtextxy displays the textstring in the viewport at the position ( x,y)

To maintain the code compatibility when using the several fonts , use textwidth and
textheight to determine the dimensions of the string .

If a string is printed with the default font using the outtext ot outtextxy ,any part of the
string that extends outside the current viewport is truncated .

Outtextxy for use in graphics mode , they will not work in the text mode.

Return value :

None




10.Settextjustify

Sets text justification for graphics mode .
Decalration :

void far settextjustify ( int horiz , int vert ) ;

Remarks :

Text output after a call to settextjustify is justified around the current position (CP)
horizontally and vertically , as specified .

The default justification settings are :

     LEFT_TEXT ( for horizontal )
     TOP_TEXT ( for vertical )


                                                                                      Page | 11
The enumeration text_justify in GRAPHICS. H provides names for the horiz and vert
settings passed to the settextjustify .

 Settextjusitfy affects the text written with outtext and cant be used with text – mode and
stream functions .

Return Values :

If invalid input is passed to the settextjustify , graph result returns -11 and the current text
justification remains unchanged .




11.Circle
Circle draws a circle

Decalration :

Void far circle(int x , int y , int radius );

ARGUMENT                      What it is Does

(x,y)                         Center point of circle

Radius                        Radius of circle

Remarks :

It draws a circle in the current drawing color.




12.Rectangle:
Draws a rectangle ( graphics mode )

Declaration :

Void far rectangle (int left , int top , int right , int bottom );

Remarks :

Rectangle draws a rectangle in the current line style , thickness and drawing color.



                                                                                     Page | 12
(left , top ) is the upper left corner of the rectangle , and (right , bottom ) is the lower right
corner .

Return Values :

None




13.Setlinestyle:

Set the current line style and width or pattern
Declaration :
void far setlinestyle ( int line style , unsigned upattern , int thickness);

Remarks :

Setlinestyle sets the style for all lines drawn by line , rectangle etc.

Return Values :

If invalid input is passed to setlinestyle , graphresult returns -11 , the current line style
remains unchanged .




14.Getmaxx ()and Getmaxy()
Return maximum x or y co-ordinates of screen.

Declaration :

Int far getmaxx (void );

Int far getmaxy (void );

Remarks :

1 . getmaxx returns the maximum X value (screen relative ) for the current graphics
driver and mode .



                                                                                        Page | 13
2. getmaxy returns the maximum Y value ( screen relative ) for the current graphics
drivers and mode .

For Example :

On a CGA in 320 * 200 mode , getmaxx returns 319 and getmaxy returns the 199

Return Values :

1) Getmaxx : maximum x screen co-ordinates.
2) Getmaxy : maximum y screen co-ordinates .



15.Cleardevice()
Clears the graphic screen .

Declaration :

Void far cleardevice (void);

Remarks :

Cleardevice erases the entire graphics screen and moves the CP (Current Position ) to
home (0,0).

Return Values : None.




16.Setfillstyle()
Set the fill pattern and color .

Declaration :

void far setfillstyle (int pattern , int color);

Remarks :

Setfillstyle set the current fill pattern and fill color

To set a user defined fill pattern , do not give a pattern of 12 (USER_FILL) to setfillstyle ,
instead , call setfillpattern .


                                                                                     Page | 14
Return Values : None.

If invalid input is passed to the setfillstyle ,graphresult return -11 and the current fill
pattern and fill color remain unchanged .



17. delay
Delay function is used to suspend execution of a program for a particular time.

Declaration :- void delay(unsigned int);

Here unsigned int is the number of milliseconds ( remember 1 second = 1000 milliseconds
). To use delay function in your program you should include the dos.h header file.




                                                                                       Page | 15
Programs of Algorithms


Program1: Direct Method Of Line Drawing
CODING:

#include<graphics.h>

#include<iostream.h>

#include<conio.h>

void main()

{

int gd=DETECT,gm;

initgraph(&gd,&gm,"");

int x1,x2,c,y1,y2,dy,dx,m;

cout<<"tttt-----------------------------n";

cout<<"tttt DIRECT LINE BY NEHA SHARMAn";

cout<<"tttt-----------------------------n";



cout<<"enter the coordinatesn";

cin>>x1>>y1>>x2>>y2;

dy=y2-y1;

dx=x2-x1;

m=dy/dx;

c=y1-m*x1;

while(x1<=x2)


                                                   Page | 16
{

if(m<=1)

{

x1=x1+1;

y1=m*x1+c;

putpixel(x1,y1,WHITE);

}

else

{

y1=y1+1;

x1=(y1-c)/m;

putpixel(x1,y1,WHITE);

}

}

getch();

}

OUTPUT:




                         Page | 17
Program 2. Digital Differential Analyzer For Line
Drawing
CODING:

#include<graphics.h>

#include<iostream.h>

#include<conio.h>

void main()

{

int gd=DETECT,gm;

initgraph(&gd,&gm,"");

int x1,x2,c,y1,y2,dy,dx,m;

cout<<"ttt------------------n";

cout<<"tttDDA By Neha Sharman";

cout<<"ttt------------------n";

cout<<"enter the coordinatesn";

cin>>x1>>y1>>x2>>y2;

dy=y2-y1;

dx=x2-x1;

m=dy/dx;

//c=y1-m*x1;

while(x1<=x2)

{

if(m<=1)

{


                                            Page | 18
x1=x1+1;

y1=y1+m;

putpixel(x1,y1,WHITE);

}

else

{

y1=y1+1;

x1=x1+(1/m);

putpixel(x1,y1,WHITE);

}

}

getch();

closegraph();

}

OUTPUT:




                         Page | 19
Program3: Bresenham Line Drawing Algorithm
CODING:

#include<graphics.h>

#include<iostream.h>

#include<conio.h>

void main()

{

int gd=DETECT,gm;

initgraph(&gd,&gm,"");

int f,fe,fne,x1,x2,y1,y2,dy,dx,m;

cout<<"-----------------";

cout<<"nBy Neha Sharman";

cout<<"-----------------";

cout<<"nenter the cordinatesn";

cin>>x1>>y1>>x2>>y2;

dy=y2-y1;

dx=x2-x1;

f=(2*dy)-dx;

while(x1<=x2)

{

if(f<=0)

{

x1=x1+1;

//y1=y1;


                                      Page | 20
f=2*dy;

putpixel(x1,y1,WHITE);

f=f+fe;

}

else

{

y1=y1+1;

x1=x1+1;

f=(2*dy)-(2*dx);

putpixel(x1,y1,WHITE);

f=f+fne;

}

}

getch();

closegraph();

}

OUTPUT:




                         Page | 21
Program 4: Direct MethodPolynomial
MethodCartesian Co-Ordinate Algortihm For
Circle Drawing
CODING:

#include<conio.h>

#include<graphics.h>

#include<math.h>

#include<iostream.h>

void main()

{

int gd=DETECT,gm;

initgraph(&gd,&gm,"");

int x1,y1,xc,yc,r,x2;

cout<<"tttt-----------------------------n";

cout<<"tttt DIRECT CIRCLE BY NEHA SHARMAn";

cout<<"tttt-----------------------------n";

cout<<"enter the x center y center and radiusn";

cin>>xc>>yc>>r;

x1=0;

x2=r/sqrt(2);

while(x1<=x2)

{

y1=sqrt(r*r-x1*x1);

putpixel(y1+xc,x1+yc,WHITE);


                                                    Page | 22
putpixel(x1+yc,y1+xc,WHITE);

putpixel(x1+yc,-y1+xc,WHITE);

putpixel(-y1+xc,x1+yc,WHITE);

putpixel(-y1+xc,-x1+yc,WHITE);

putpixel(-x1+yc,-y1+xc,WHITE);

putpixel(-x1+yc,y1+xc,WHITE);

putpixel(y1+xc,-x1+yc,WHITE);

x1=x1+1;

}

getch();

}

OUTPUT:




                                 Page | 23
Program 5: Polar Circle Drawing Algorithm
CODING:

#include<conio.h>

#include<graphics.h>

#include<math.h>

#include<iostream.h>

void main()

{

int gd=DETECT,gm;

initgraph(&gd,&gm,"");

float x1,y1,xc,yc,r,t;

cout<<"enter the x center y center and radius";

cin>>xc>>yc>>r;

x1=0;

y1=r;

t=1/r;

while(x1<=y1)

{

putpixel(y1+xc,x1+yc,WHITE);

putpixel(x1+yc,y1+xc,WHITE);

putpixel(x1+yc,-y1+xc,WHITE);

putpixel(-y1+xc,x1+yc,WHITE);

putpixel(-y1+xc,-x1+yc,WHITE);

putpixel(-x1+yc,-y1+xc,WHITE);


                                                  Page | 24
putpixel(-x1+yc,y1+xc,WHITE);

putpixel(y1+xc,-x1+yc,WHITE);

float temp=y1;

y1=(y1*cos(t))+(x1*sin(t));

x1=(x1*cos(t))-(temp*sin(t));

}



getch();

}

OUTPUT:




                                Page | 25
Program 6: Bresenham Circle Drawing
Algorithm
CODING:

#include<conio.h>

#include<graphics.h>

#include<math.h>

#include<iostream.h>

void main()

{

int gd=DETECT,gm;

initgraph(&gd,&gm,"");

float x1,y1,f,xc,yc,r,t;

cout<<"enter the x center y center and radius";

cin>>xc>>yc>>r;

x1=0;

y1=r;

f=3-(2*r);

while(x1<=y1)

{

if(f<=0)

{

f=f+6+4*x;

x=x+1;

}


                                                  Page | 26
else

{

f=f+10+(4*x)-(4*y);

x=x+1;

y=y-1;

}

putpixel(y1+xc,x1+yc,WHITE);

putpixel(x1+yc,y1+xc,WHITE);

putpixel(x1+yc,-y1+xc,WHITE);

putpixel(-y1+xc,x1+yc,WHITE);

putpixel(-y1+xc,-x1+yc,WHITE);

putpixel(-x1+yc,-y1+xc,WHITE);

putpixel(-x1+yc,y1+xc,WHITE);

putpixel(y1+xc,-x1+yc,WHITE);

}

getch();

closegraph();

                                 }




                                     Page | 27
Program 7: Mid Point Circle Drawing Algorithm
CODING:

#include<conio.h>

#include<graphics.h>

#include<math.h>

#include<iostream.h>

void main()

{

int gd=DETECT,gm;

initgraph(&gd,&gm,"");

float x1,y1,f,xc,yc,r;

cout<<"MIDPOINT CIRCLEBY NEHA SHARMAn";

cout<<"enter the x center y center and radiusn";

cin>>xc>>yc>>r;

x1=0;

y1=r;

f=1-r;

while(x1<=y1)

{

if(f<=0)

{

f=f+3+2*x1;

x1=x1+1;

}


                                                    Page | 28
else

{

f=f+5+(2*x1)-(2*y1);

x1=x1+1;

y1=y1-1;

}

putpixel(y1+xc,x1+yc,WHITE);

putpixel(x1+xc,y1+yc,WHITE);

putpixel(x1+xc,-y1+yc,WHITE);

putpixel(-y1+xc,x1+yc,WHITE);

putpixel(-y1+xc,-x1+yc,WHITE);

putpixel(-x1+xc,-y1+yc,WHITE);

putpixel(-x1+xc,y1+yc,WHITE);

putpixel(y1+xc,-x1+yc,WHITE);

}

getch();

closegraph();

}

OUTPUT:




                                 Page | 29
Program 8: DirectPolynomial Algorithm Of
Ellipse Drawing
CODING:

#include<conio.h>

#include<iostream.h>

#include<graphics.h>

#include<math.h>

void main()

{

int gd=DETECT,gm;

initgraph(&gd,&gm,"");

float xc,yc,rx,ry,x1,y1,x2;



cout<<"DIRECT ELLIPSE BY NEHA SHARMAn";

cout<<"enter xc,yc,x radius,y radiusn" ;

cin>>xc>>yc>>rx>>ry;

x1=0;

x2=rx;

while(x1<=x2)

{

y1=(ry/rx)*sqrt((rx*rx)-(x1*x1));

putpixel(x1+xc,y1+yc,WHITE);

putpixel(x1+xc,-y1+yc,WHITE);

putpixel(-x1+xc,-y1+yc,WHITE);


                                            Page | 30
putpixel(-x1+xc,y1+yc,WHITE);

x1=x1+1;

}



getch();

closegraph();

}



OUTPUT:




                                Page | 31
Program 9: Polar Ellipse Drawing Algorithm
CODING:

#include<conio.h>

#include<iostream.h>

#include<graphics.h>

#include<math.h>

void main()

{

int gd=DETECT,gm;

initgraph(&gd,&gm,"");

float xc,yc,rx,ry,t1,t2,x1,y1,x2;



cout<<"POLAR ELLIPSE BY NEHA SHARMAn";

cout<<"enter xc,yc,x radius,y radiusn" ;

cin>>xc>>yc>>rx>>ry;

t1=0;

t2=90;

while(t1<=t2)

{

y1=ry*sin(t1);

x1=rx*cos(t1);

putpixel(x1+xc,y1+yc,WHITE);

putpixel(x1+xc,-y1+yc,WHITE);

putpixel(-x1+xc,-y1+yc,WHITE);


                                            Page | 32
putpixel(-x1+xc,y1+yc,WHITE);

t1=t1+1;

}



getch();

closegraph();

}



OUTPUT:




                                Page | 33
10. Program To Draw Ellipse Using Midpoint
Ellipse Algorithm
Coding:
#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
void main()
{
int gd=DETECT, gm;
initgraph(&gd,&gm,"");
float xc,yc,x,y,xr,yr,f;
cout<<”tttt------------------------------------”;
cout<<"ntttMID POINT ELLIPSE BY MOHITn";

cout<<”ntttt---------------------------------------”;
cout<<"nEnter the coordinates xc,yc,xr ,yr";
cin>>xc>>yc>>xr>>yr;
x=0;
y=yr;
f=(yr*yr)+(xr*xr)/4-(xr*xr)*yr;
while(2*(yr*yr)*x<=2*(xr*xr)*y)
{
if(f<=0)
{
f=f+(3+(2*x))*(yr*yr);
x++;
putpixel(x+xc,y+yc,WHITE);
putpixel(-x+xc,y+yc,WHITE);
putpixel(-x+xc,-y+yc,WHITE);

                                                             Page | 34
putpixel(x+xc,-y+yc,WHITE);
}
else
{
f=f+3*(yr*yr)+2*x*(yr*yr)+2*(xr*xr)-2*y*(xr*xr);
x++;
y--;
putpixel(x+xc,y+yc,WHITE);
putpixel(-x+xc,y+yc,WHITE);
putpixel(-x+xc,-y+yc,WHITE);
putpixel(x+xc,-y+yc,WHITE);
}
}
f=(yr*yr)/4-2*(xr*xr)*yr+(xr*xr);
while(y>=0)
{
if(f<=0)
{
f=f+(3-(2*y))*(xr*xr);
x++;
y--;
putpixel(x+xc,y+yc,WHITE);
putpixel(-x+xc,y+yc,WHITE);
putpixel(-x+xc,-y+yc,WHITE);
putpixel(x+xc,-y+yc,WHITE);
}
else
{
f=f+2*(yr*yr)+2*x*(yr*yr)+3*(xr*xr)-2*y*(xr*xr);
y--;


                                                   Page | 35
putpixel(x+xc,y+yc,WHITE);
putpixel(-x+xc,y+yc,WHITE);
putpixel(-x+xc,-y+yc,WHITE);
putpixel(x+xc,-y+yc,WHITE);
}
}
getch();
closegraph();
}



OUTPUT:



    Mid Point Ellipse Drawing Algorithm




                                          Page | 36

Weitere ähnliche Inhalte

Was ist angesagt?

COMPUTER GRAPHICS PROJECT REPORT
COMPUTER GRAPHICS PROJECT REPORTCOMPUTER GRAPHICS PROJECT REPORT
COMPUTER GRAPHICS PROJECT REPORTvineet raj
 
Liang barsky Line Clipping Algorithm
Liang barsky Line Clipping AlgorithmLiang barsky Line Clipping Algorithm
Liang barsky Line Clipping AlgorithmArvind Kumar
 
Bezier curve & B spline curve
Bezier curve  & B spline curveBezier curve  & B spline curve
Bezier curve & B spline curveArvind Kumar
 
Introduction to computer graphics
Introduction to computer graphicsIntroduction to computer graphics
Introduction to computer graphicsAmandeep Kaur
 
Graphics software
Graphics softwareGraphics software
Graphics softwareMohd Arif
 
Line drawing algo.
Line drawing algo.Line drawing algo.
Line drawing algo.Mohd Arif
 
Line Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - NotesLine Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - NotesOmprakash Chauhan
 
2D transformation (Computer Graphics)
2D transformation (Computer Graphics)2D transformation (Computer Graphics)
2D transformation (Computer Graphics)Timbal Mayank
 
Polygon filling algorithm
Polygon filling algorithmPolygon filling algorithm
Polygon filling algorithmAparna Joshi
 
Computer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsComputer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsKandarp Tiwari
 
Introduction to computer graphics
Introduction to computer graphicsIntroduction to computer graphics
Introduction to computer graphicsKamal Acharya
 
Computer Graphics Project- The Running Train
Computer Graphics Project- The Running TrainComputer Graphics Project- The Running Train
Computer Graphics Project- The Running TrainAmit Kumar
 
Dda line algorithm presentatiion
Dda line algorithm presentatiionDda line algorithm presentatiion
Dda line algorithm presentatiionMuhammadHamza401
 
hidden surface elimination using z buffer algorithm
hidden surface elimination using z buffer algorithmhidden surface elimination using z buffer algorithm
hidden surface elimination using z buffer algorithmrajivagarwal23dei
 
Raster scan system & random scan system
Raster scan system & random scan systemRaster scan system & random scan system
Raster scan system & random scan systemshalinikarunakaran1
 

Was ist angesagt? (20)

Computer Graphics
Computer GraphicsComputer Graphics
Computer Graphics
 
COMPUTER GRAPHICS PROJECT REPORT
COMPUTER GRAPHICS PROJECT REPORTCOMPUTER GRAPHICS PROJECT REPORT
COMPUTER GRAPHICS PROJECT REPORT
 
Liang barsky Line Clipping Algorithm
Liang barsky Line Clipping AlgorithmLiang barsky Line Clipping Algorithm
Liang barsky Line Clipping Algorithm
 
Computer graphics ppt
Computer graphics pptComputer graphics ppt
Computer graphics ppt
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
 
Bezier curve & B spline curve
Bezier curve  & B spline curveBezier curve  & B spline curve
Bezier curve & B spline curve
 
Introduction to computer graphics
Introduction to computer graphicsIntroduction to computer graphics
Introduction to computer graphics
 
Graphics software
Graphics softwareGraphics software
Graphics software
 
Line drawing algo.
Line drawing algo.Line drawing algo.
Line drawing algo.
 
Line Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - NotesLine Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - Notes
 
Multimedia chapter 5
Multimedia chapter 5Multimedia chapter 5
Multimedia chapter 5
 
2D transformation (Computer Graphics)
2D transformation (Computer Graphics)2D transformation (Computer Graphics)
2D transformation (Computer Graphics)
 
Polygon filling algorithm
Polygon filling algorithmPolygon filling algorithm
Polygon filling algorithm
 
Computer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsComputer Graphics Lab File C Programs
Computer Graphics Lab File C Programs
 
Introduction to computer graphics
Introduction to computer graphicsIntroduction to computer graphics
Introduction to computer graphics
 
Computer Graphics Project- The Running Train
Computer Graphics Project- The Running TrainComputer Graphics Project- The Running Train
Computer Graphics Project- The Running Train
 
Dda line algorithm presentatiion
Dda line algorithm presentatiionDda line algorithm presentatiion
Dda line algorithm presentatiion
 
hidden surface elimination using z buffer algorithm
hidden surface elimination using z buffer algorithmhidden surface elimination using z buffer algorithm
hidden surface elimination using z buffer algorithm
 
Raster scan system & random scan system
Raster scan system & random scan systemRaster scan system & random scan system
Raster scan system & random scan system
 
3D Display
3D Display3D Display
3D Display
 

Andere mochten auch

Basics of Computer graphics lab
Basics of Computer graphics labBasics of Computer graphics lab
Basics of Computer graphics labPriya Goyal
 
COMPUTER GRAPHICS LAB MANUAL
COMPUTER GRAPHICS LAB MANUALCOMPUTER GRAPHICS LAB MANUAL
COMPUTER GRAPHICS LAB MANUALVivek Kumar Sinha
 
Computer Graphics Programes
Computer Graphics ProgramesComputer Graphics Programes
Computer Graphics ProgramesAbhishek Sharma
 
SE Computer, Programming Laboratory(210251) University of Pune
SE Computer, Programming Laboratory(210251) University of PuneSE Computer, Programming Laboratory(210251) University of Pune
SE Computer, Programming Laboratory(210251) University of PuneBhavesh Shah
 
Graphics practical lab manual
Graphics practical lab manualGraphics practical lab manual
Graphics practical lab manualVivek Kumar Sinha
 
Graphics in C programming
Graphics in C programmingGraphics in C programming
Graphics in C programmingKamal Acharya
 
Computer graphics file
Computer graphics fileComputer graphics file
Computer graphics fileaman1001
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manualAnkit Kumar
 
Lecture on graphics
Lecture on graphicsLecture on graphics
Lecture on graphicsRafi_Dar
 
C Graphics Functions
C Graphics FunctionsC Graphics Functions
C Graphics FunctionsSHAKOOR AB
 
Computer Graphics Applications
Computer Graphics ApplicationsComputer Graphics Applications
Computer Graphics ApplicationsSaravana Priya
 
Midpoint circle algo
Midpoint circle algoMidpoint circle algo
Midpoint circle algoMohd Arif
 
Graphics Programming in C under GNU Linux (Ubuntu distribution)
Graphics Programming in C under GNU Linux (Ubuntu distribution)Graphics Programming in C under GNU Linux (Ubuntu distribution)
Graphics Programming in C under GNU Linux (Ubuntu distribution)Tushar B Kute
 
Computer graphics lab assignment
Computer graphics lab assignmentComputer graphics lab assignment
Computer graphics lab assignmentAbdullah Al Shiam
 
Computer graphics
Computer graphicsComputer graphics
Computer graphicsamitsarda3
 
Area filling algo
Area filling algoArea filling algo
Area filling algoPrince Soni
 

Andere mochten auch (20)

Basics of Computer graphics lab
Basics of Computer graphics labBasics of Computer graphics lab
Basics of Computer graphics lab
 
COMPUTER GRAPHICS LAB MANUAL
COMPUTER GRAPHICS LAB MANUALCOMPUTER GRAPHICS LAB MANUAL
COMPUTER GRAPHICS LAB MANUAL
 
Computer Graphics Programes
Computer Graphics ProgramesComputer Graphics Programes
Computer Graphics Programes
 
Graphics Programming in C
Graphics Programming in CGraphics Programming in C
Graphics Programming in C
 
Introduction to graphics programming in c
Introduction to graphics programming in cIntroduction to graphics programming in c
Introduction to graphics programming in c
 
SE Computer, Programming Laboratory(210251) University of Pune
SE Computer, Programming Laboratory(210251) University of PuneSE Computer, Programming Laboratory(210251) University of Pune
SE Computer, Programming Laboratory(210251) University of Pune
 
Graphics practical lab manual
Graphics practical lab manualGraphics practical lab manual
Graphics practical lab manual
 
Graphics in C++
Graphics in C++Graphics in C++
Graphics in C++
 
Graphics in C programming
Graphics in C programmingGraphics in C programming
Graphics in C programming
 
Computer graphics file
Computer graphics fileComputer graphics file
Computer graphics file
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
 
Lecture on graphics
Lecture on graphicsLecture on graphics
Lecture on graphics
 
C Graphics Functions
C Graphics FunctionsC Graphics Functions
C Graphics Functions
 
Computer Graphics
Computer GraphicsComputer Graphics
Computer Graphics
 
Computer Graphics Applications
Computer Graphics ApplicationsComputer Graphics Applications
Computer Graphics Applications
 
Midpoint circle algo
Midpoint circle algoMidpoint circle algo
Midpoint circle algo
 
Graphics Programming in C under GNU Linux (Ubuntu distribution)
Graphics Programming in C under GNU Linux (Ubuntu distribution)Graphics Programming in C under GNU Linux (Ubuntu distribution)
Graphics Programming in C under GNU Linux (Ubuntu distribution)
 
Computer graphics lab assignment
Computer graphics lab assignmentComputer graphics lab assignment
Computer graphics lab assignment
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
Area filling algo
Area filling algoArea filling algo
Area filling algo
 

Ähnlich wie Computer Graphics Practical

Computer graphics
Computer graphics Computer graphics
Computer graphics shafiq sangi
 
computer graphics unit 1.ppt
computer graphics unit 1.pptcomputer graphics unit 1.ppt
computer graphics unit 1.pptoumiarashid
 
Computer graphics Applications and System Overview
Computer graphics Applications and System OverviewComputer graphics Applications and System Overview
Computer graphics Applications and System OverviewRAJARATNAS
 
topic_- introduction of computer graphics.
   topic_- introduction of computer graphics.   topic_- introduction of computer graphics.
topic_- introduction of computer graphics.Aniketkumar204
 
Introduction to Computer Graphics
Introduction to Computer GraphicsIntroduction to Computer Graphics
Introduction to Computer GraphicsAbdullah Khan
 
Cg applications
Cg applicationsCg applications
Cg applicationsalldesign
 
Introduction_computer_graphics_unit-1.pptx
Introduction_computer_graphics_unit-1.pptxIntroduction_computer_graphics_unit-1.pptx
Introduction_computer_graphics_unit-1.pptxshivanipuran1
 
Applications of cg
Applications of cgApplications of cg
Applications of cgAnkit Garg
 
unit1_updated.pptx
unit1_updated.pptxunit1_updated.pptx
unit1_updated.pptxRYZEN14
 
Computer graphics 9068
Computer graphics  9068Computer graphics  9068
Computer graphics 90681061992
 
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithm
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithmComputer Graphics Introduction, Open GL, Line and Circle drawing algorithm
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithmDeepika Walanjkar
 
Introduction of Computer aided Design
Introduction of Computer aided DesignIntroduction of Computer aided Design
Introduction of Computer aided DesignMuthukumar V
 

Ähnlich wie Computer Graphics Practical (20)

Graphics file
Graphics fileGraphics file
Graphics file
 
Computer graphics
Computer graphics Computer graphics
Computer graphics
 
computer graphics unit 1.ppt
computer graphics unit 1.pptcomputer graphics unit 1.ppt
computer graphics unit 1.ppt
 
Digital design
Digital designDigital design
Digital design
 
Computer graphics Applications and System Overview
Computer graphics Applications and System OverviewComputer graphics Applications and System Overview
Computer graphics Applications and System Overview
 
topic_- introduction of computer graphics.
   topic_- introduction of computer graphics.   topic_- introduction of computer graphics.
topic_- introduction of computer graphics.
 
CG_1.pdf
CG_1.pdfCG_1.pdf
CG_1.pdf
 
computer graphics unit 1-I.pptx
computer graphics unit 1-I.pptxcomputer graphics unit 1-I.pptx
computer graphics unit 1-I.pptx
 
Computer graphics by bahadar sher
Computer graphics by bahadar sherComputer graphics by bahadar sher
Computer graphics by bahadar sher
 
Introduction to Computer Graphics
Introduction to Computer GraphicsIntroduction to Computer Graphics
Introduction to Computer Graphics
 
Compute graphics
Compute graphicsCompute graphics
Compute graphics
 
Cg
CgCg
Cg
 
Cg applications
Cg applicationsCg applications
Cg applications
 
Introduction_computer_graphics_unit-1.pptx
Introduction_computer_graphics_unit-1.pptxIntroduction_computer_graphics_unit-1.pptx
Introduction_computer_graphics_unit-1.pptx
 
Applications of cg
Applications of cgApplications of cg
Applications of cg
 
unit1_updated.pptx
unit1_updated.pptxunit1_updated.pptx
unit1_updated.pptx
 
Computer graphics 9068
Computer graphics  9068Computer graphics  9068
Computer graphics 9068
 
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithm
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithmComputer Graphics Introduction, Open GL, Line and Circle drawing algorithm
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithm
 
AutoCAD Tutorial AB.pptx
AutoCAD Tutorial AB.pptxAutoCAD Tutorial AB.pptx
AutoCAD Tutorial AB.pptx
 
Introduction of Computer aided Design
Introduction of Computer aided DesignIntroduction of Computer aided Design
Introduction of Computer aided Design
 

Mehr von Neha Sharma

Transportation Problem in Operational Research
Transportation Problem in Operational ResearchTransportation Problem in Operational Research
Transportation Problem in Operational ResearchNeha Sharma
 
Microsoft Surface
Microsoft SurfaceMicrosoft Surface
Microsoft SurfaceNeha Sharma
 
Terrorist Attacks
Terrorist AttacksTerrorist Attacks
Terrorist AttacksNeha Sharma
 
Microsoft Surface
Microsoft Surface Microsoft Surface
Microsoft Surface Neha Sharma
 
Top Reality Shows
Top Reality ShowsTop Reality Shows
Top Reality ShowsNeha Sharma
 
Interesting Facts about Maths
Interesting Facts about MathsInteresting Facts about Maths
Interesting Facts about MathsNeha Sharma
 

Mehr von Neha Sharma (9)

Web Browsers
Web BrowsersWeb Browsers
Web Browsers
 
Transportation Problem in Operational Research
Transportation Problem in Operational ResearchTransportation Problem in Operational Research
Transportation Problem in Operational Research
 
Microsoft Surface
Microsoft SurfaceMicrosoft Surface
Microsoft Surface
 
Terrorist Attacks
Terrorist AttacksTerrorist Attacks
Terrorist Attacks
 
Microsoft Surface
Microsoft Surface Microsoft Surface
Microsoft Surface
 
Top Reality Shows
Top Reality ShowsTop Reality Shows
Top Reality Shows
 
IPv6
IPv6IPv6
IPv6
 
Steganography
SteganographySteganography
Steganography
 
Interesting Facts about Maths
Interesting Facts about MathsInteresting Facts about Maths
Interesting Facts about Maths
 

Kürzlich hochgeladen

React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 

Kürzlich hochgeladen (20)

React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 

Computer Graphics Practical

  • 1. PUNJAB COLLEGE OF TECHNICAL EDUCATION PRACTICAL FILE BC-507 SUBMITTED BY: SUBMITTED BY: Ms.Richa Sharma Neha Sharma Assistant Professor (94972346352) P.C.T.E. BCA-5th Sem Page | 0
  • 2. Index S.No Contents Page no. Remarks 1. Introduction to graphics 2 2. Applications of graphics 3-5 3. Graphics In-built functions 6-15 4. Programs of Algorithm 16-26 a) Direct method of line b) DDA Algorithm c) Bresenham algorithm d) Direct method of Circle e) Polar Circle f) Bresenham Circle g) Midpoint Circle h) Direct Ellipse i) Polar Ellipse j) Mid point Ellipse 5. Static Application 6. Ist dynamic Application 7. IInd Dynamic Application Page | 1
  • 3. 1. Introduction To Graphics Computer graphics are graphics created using computers and, more generally, the representation and manipulation of image data by a computer with help from specialized software and hardware. The development of computer graphics has made computers easier to interact with, and better for understanding and interpreting many types of data. Developments in computer graphics have had a profound impact on many types of media and have revolutionized animation, movies and the video game industry. the term computer graphics refers to several different things: the representation and manipulation of image data by a computer the various technologies used to create and manipulate images the images so produced, and the sub-field of computer science which studies methods for digitally synthesizing and manipulating visual content Page | 2
  • 4. 2. Application of Graphics Computer graphics may be used in the following areas: COMPUTER AIDED DESIGN PRESENTATION GRAPHICS COMPUTER ART ENTERTAINMENT EDUCATION AND TRAINING VISUALIZATION IMAGE PROCESSING GRAPHICAL USER INTERFACE VIDEO GAMES Computers have become a powerful tool for the rapid and economical production of pictures. Advances in computer technology have made interactive computer graphics a practical tool. Today, computer graphics is used in the areas as science, engineering, medicine, business, industry, government, art, entertainment, advertising, education, and training. COMPUTER AIDED DESIGN A major use of computer graphics is in design processes, particularly for engineering and architectural systems. For some design applications; objects are first displayed in a wireframe outline form that shows the overall sham and internal features of objects. Software packages for CAD applications typically provide the designer with a multi- window environment. Each window can show enlarged sections or different views of objects. Standard shapes for electrical, electronic, and logic circuits are often supplied by the design package. The connections between the components have been mad automatically. Animations are often used in CAD applications. Real-time animations using wire frame displays are useful for testing performance of a vehicle. Wire frame models allow the designer to see the interior parts of the vehicle during motion. When object designs are complete, realistic lighting models and surface rendering are applied. Manufacturing process of object can also be controlled through CAD. Page | 3
  • 5. Interactive graphics methods are used to layout the buildings. Three-dimensional interior layouts and lighting also provided. With virtual-reality systems, the designers can go for a simulated walk inside the building. PRESENTATION GRAPHICS  It is used to produce illustrations for reports or to generate slide for with projections.  Examples of presentation graphics are bar charts, line graphs, surface graphs, pie charts and displays showing relationships between parameters.  3-D graphics can provide more attraction to the presentation. COMPUTER ART  Computer graphics methods are widely used in both fine are and commercial art applications.  The artist uses a combination of 3D modeling packages, texture mapping, drawing programs and CAD software.  Pen plotter with specially designed software can create “automatic art”.  “Mathematical Art” can be produced using mathematical functions, fractal procedures.  These methods are also applied in commercial art.  Photorealistic techniques are used to render images of a product.  Animations are also used frequently in advertising, and television commercials are produced frame by frame. Film animations require 24 frames for each second in the animation sequence.  A common graphics method employed in many commercials is morphing, where one object is transformed into another. ENTERTAINMENT  CG methods are now commonly used in making motion pictures, music videos and television shows.  Many TV series regularly employ computer graphics method.  Graphics objects can be combined with a live action. EDUCATION AND TRAINING  Computer-generated models of physical, financial and economic systems are often used as educational aids. Page | 4
  • 6. For some training applications, special systems are designed.  Eg. Training of ship captains, aircraft pilots etc.,  Some simulators have no video screens, but most simulators provide graphics screen for visual operation. Some of them provide only the control panel. VISUALIZATION  The numerical and scientific data are converted to a visual form for analysis and to study the behavior called visualization.  Producing graphical representation for scientific data sets are calls scientific visualization.  And business visualization is used to represent the data sets related to commerce and industry.  The visualization can be either 2D or 3D. IMAGE PROCESSING  Computer graphics is used to create a picture.  Image processing applies techniques to modify or interpret existing pictures.  To apply image processing methods, the image must be digitized first.  Medical applications also make extensive use of image processing techniques for picture enhancements, simulations of operations, etc. GRAPHICAL USER INTERFACE  Nowadays software packages provide graphics user interface (GUI) for the user to work easily.  A major component in GUI is a window.  Multiple windows can be opened at a time.  To activate any one of the window, the user needs just to check on that window.  Menus and icons are used for fast selection of processing operations.  Icons are used as shortcut to perform functions. The advantages of icons are which takes less screen space.  And some other interfaces like text box, buttons, and list are also used. Page | 5
  • 7. 3. Inbuilt Functions: 1. Arc Arc draws a circular arc in the current drawing color. Declaration: Void arc(int x, int y , int Stangle, int endangle , int radius ) ARGUMENT What it is Does (x,y) Center point of arc Stangle Start angle in degrees Endangle End angle in degrees Radius Radius of arc The arc travels from Stangle to Endangle If Stangle =0 and Endangle = 360 , the call to arc draws a complete circle 2. Initgraph Initializes the graphic system Decalaration: Void far initgraph(int far * graphdriver); Int far * graphmode , char far *pathdriver); Remarks: To start the graphics system , you must first call the initgraph Initgraph initializes the graphics system by loading a graphics the driver from disk (or validating a registered driver ) then putting the system into graphics mode . Page | 6
  • 8. Initgraph also resets all the graphics settings (color ,palette ,current position , viewport ,etc) to their defaults , then resets graphresult to 0 . Argument What it is does *graphdriver Integer that specifies the graphic driver to be used . you can give graphdriver a value using a constant of the graphics_drivers enumeration type . *graphmode Integer that specifies the initial graphics mode .(unless *graphdriver =DETECT). If *graphdriver =DETECT , initgraph sets *graphmode to the highest resolution available for the detected driver . You can give the *graphmode a value using a constant of the graphics_modes enumeration type . *graphdriver and *graphmode must be set to the valid graphics _drivers and graphics_mode values or you will get unpredictable results . ( the exception is graphdriver = DETECT). After a call to the initgraph , *graphdriver is set to the current graphics driver , and *graphmode is set to the current graphics mode . 3. closegraph Shuts down the graphics system Declaration : void far closegraph( void ); Remarks : Closegraph deallocates all memory allocated by the graphics system . It then restores the screen to the mode it was in before you called initgraph . ( the graphics system deallocates memory such as the drivers , fonts , and an internal buffer , through a call to the _graphfreemem) Page | 7
  • 9. Return Value : None 4.line Line draws a line between the two specified points Declaration : Void far line ( int x1, int y1 , int x2 , int y2 ); Remarks : Line draws a line from the ( x1, y1 ) to ( x2,y2 ) using the current color , line style nad thick ness . it does not the update the current position (cp). 5. setcolor Setcolor sets the current drawing color Declaration: Void far setcolor( int color) Remarks : Setcolor sets the current drawing color to color , which can range from 0 to getmaxcolor To select a drawing color is the value that pixels are set to the when the program draws lines etc. Return value : Setcolor does not return 6.setbkcolor Page | 8
  • 10. Setbkcolor sets the current background the color using the palette Declaration : Void far setbkcolor( int color ); Remarks : Setbkcolor sets the background to the color specified by color Color : color is either a number or symbolic name specifying the color to set For example , if you want to set the background color to blue , you can call setbkcolor (BLUE) /* or */ setbkcolor(1) On CGA and EGA systems , setbkcolor changes the background color by changing the first entry in the palette. Return: Setbkcolor does not return 7.Ellipse Ellipse draws an elliptical arc Declaration : Void far ellipse ( int x, int y , int stangle , int endangle , int xradius , int yradius ) ; Remarks : Ellipse draws an elliptical arc in the current drawing color . Argument What it is ( x,y) Center of ellipse Xradius Horizontal axis Yradius Vertical axis Page | 9
  • 11. Stangle starting angle Endangle ending angle The ellipse travels from stangle to endangle . If stangle = 0 and endangle = 360 , the call to the ellipse draws a complete ellipse . The linestyle parameter does not affect the arcs , circles , ellipse or pie slices . only the thickness parameter is used . Return value : None 8.Flood fill : Flood fills a bounded region Declaration : void far floodfill( int x, int y , int border ); Remarks : Floodfill fills an enclosed area on bitmap devices . The area bounded by the color border is flooded with the current fill pattern and fill color . (x,y) is the “seed point ”.  If the seed is within an enclosed area , the inside will be filled .  If the seed is outside the enclosed area, the exterior will be filled . Use fillpoly instead of floodfill whenever possible so you can maintain code compatibility with future versions . 9.Outtextxy Page | 10
  • 12. Outtextxy displays a string at the specified location ( graphics mode ) Declaration : Void far outtextxy (int x , int y , char far * textstring ); Remarks : Outtextxy displays a text string using the current justification settings and the current font , direction and size . Outtextxy displays the textstring in the viewport at the position ( x,y) To maintain the code compatibility when using the several fonts , use textwidth and textheight to determine the dimensions of the string . If a string is printed with the default font using the outtext ot outtextxy ,any part of the string that extends outside the current viewport is truncated . Outtextxy for use in graphics mode , they will not work in the text mode. Return value : None 10.Settextjustify Sets text justification for graphics mode . Decalration : void far settextjustify ( int horiz , int vert ) ; Remarks : Text output after a call to settextjustify is justified around the current position (CP) horizontally and vertically , as specified . The default justification settings are :  LEFT_TEXT ( for horizontal )  TOP_TEXT ( for vertical ) Page | 11
  • 13. The enumeration text_justify in GRAPHICS. H provides names for the horiz and vert settings passed to the settextjustify . Settextjusitfy affects the text written with outtext and cant be used with text – mode and stream functions . Return Values : If invalid input is passed to the settextjustify , graph result returns -11 and the current text justification remains unchanged . 11.Circle Circle draws a circle Decalration : Void far circle(int x , int y , int radius ); ARGUMENT What it is Does (x,y) Center point of circle Radius Radius of circle Remarks : It draws a circle in the current drawing color. 12.Rectangle: Draws a rectangle ( graphics mode ) Declaration : Void far rectangle (int left , int top , int right , int bottom ); Remarks : Rectangle draws a rectangle in the current line style , thickness and drawing color. Page | 12
  • 14. (left , top ) is the upper left corner of the rectangle , and (right , bottom ) is the lower right corner . Return Values : None 13.Setlinestyle: Set the current line style and width or pattern Declaration : void far setlinestyle ( int line style , unsigned upattern , int thickness); Remarks : Setlinestyle sets the style for all lines drawn by line , rectangle etc. Return Values : If invalid input is passed to setlinestyle , graphresult returns -11 , the current line style remains unchanged . 14.Getmaxx ()and Getmaxy() Return maximum x or y co-ordinates of screen. Declaration : Int far getmaxx (void ); Int far getmaxy (void ); Remarks : 1 . getmaxx returns the maximum X value (screen relative ) for the current graphics driver and mode . Page | 13
  • 15. 2. getmaxy returns the maximum Y value ( screen relative ) for the current graphics drivers and mode . For Example : On a CGA in 320 * 200 mode , getmaxx returns 319 and getmaxy returns the 199 Return Values : 1) Getmaxx : maximum x screen co-ordinates. 2) Getmaxy : maximum y screen co-ordinates . 15.Cleardevice() Clears the graphic screen . Declaration : Void far cleardevice (void); Remarks : Cleardevice erases the entire graphics screen and moves the CP (Current Position ) to home (0,0). Return Values : None. 16.Setfillstyle() Set the fill pattern and color . Declaration : void far setfillstyle (int pattern , int color); Remarks : Setfillstyle set the current fill pattern and fill color To set a user defined fill pattern , do not give a pattern of 12 (USER_FILL) to setfillstyle , instead , call setfillpattern . Page | 14
  • 16. Return Values : None. If invalid input is passed to the setfillstyle ,graphresult return -11 and the current fill pattern and fill color remain unchanged . 17. delay Delay function is used to suspend execution of a program for a particular time. Declaration :- void delay(unsigned int); Here unsigned int is the number of milliseconds ( remember 1 second = 1000 milliseconds ). To use delay function in your program you should include the dos.h header file. Page | 15
  • 17. Programs of Algorithms Program1: Direct Method Of Line Drawing CODING: #include<graphics.h> #include<iostream.h> #include<conio.h> void main() { int gd=DETECT,gm; initgraph(&gd,&gm,""); int x1,x2,c,y1,y2,dy,dx,m; cout<<"tttt-----------------------------n"; cout<<"tttt DIRECT LINE BY NEHA SHARMAn"; cout<<"tttt-----------------------------n"; cout<<"enter the coordinatesn"; cin>>x1>>y1>>x2>>y2; dy=y2-y1; dx=x2-x1; m=dy/dx; c=y1-m*x1; while(x1<=x2) Page | 16
  • 19. Program 2. Digital Differential Analyzer For Line Drawing CODING: #include<graphics.h> #include<iostream.h> #include<conio.h> void main() { int gd=DETECT,gm; initgraph(&gd,&gm,""); int x1,x2,c,y1,y2,dy,dx,m; cout<<"ttt------------------n"; cout<<"tttDDA By Neha Sharman"; cout<<"ttt------------------n"; cout<<"enter the coordinatesn"; cin>>x1>>y1>>x2>>y2; dy=y2-y1; dx=x2-x1; m=dy/dx; //c=y1-m*x1; while(x1<=x2) { if(m<=1) { Page | 18
  • 21. Program3: Bresenham Line Drawing Algorithm CODING: #include<graphics.h> #include<iostream.h> #include<conio.h> void main() { int gd=DETECT,gm; initgraph(&gd,&gm,""); int f,fe,fne,x1,x2,y1,y2,dy,dx,m; cout<<"-----------------"; cout<<"nBy Neha Sharman"; cout<<"-----------------"; cout<<"nenter the cordinatesn"; cin>>x1>>y1>>x2>>y2; dy=y2-y1; dx=x2-x1; f=(2*dy)-dx; while(x1<=x2) { if(f<=0) { x1=x1+1; //y1=y1; Page | 20
  • 23. Program 4: Direct MethodPolynomial MethodCartesian Co-Ordinate Algortihm For Circle Drawing CODING: #include<conio.h> #include<graphics.h> #include<math.h> #include<iostream.h> void main() { int gd=DETECT,gm; initgraph(&gd,&gm,""); int x1,y1,xc,yc,r,x2; cout<<"tttt-----------------------------n"; cout<<"tttt DIRECT CIRCLE BY NEHA SHARMAn"; cout<<"tttt-----------------------------n"; cout<<"enter the x center y center and radiusn"; cin>>xc>>yc>>r; x1=0; x2=r/sqrt(2); while(x1<=x2) { y1=sqrt(r*r-x1*x1); putpixel(y1+xc,x1+yc,WHITE); Page | 22
  • 25. Program 5: Polar Circle Drawing Algorithm CODING: #include<conio.h> #include<graphics.h> #include<math.h> #include<iostream.h> void main() { int gd=DETECT,gm; initgraph(&gd,&gm,""); float x1,y1,xc,yc,r,t; cout<<"enter the x center y center and radius"; cin>>xc>>yc>>r; x1=0; y1=r; t=1/r; while(x1<=y1) { putpixel(y1+xc,x1+yc,WHITE); putpixel(x1+yc,y1+xc,WHITE); putpixel(x1+yc,-y1+xc,WHITE); putpixel(-y1+xc,x1+yc,WHITE); putpixel(-y1+xc,-x1+yc,WHITE); putpixel(-x1+yc,-y1+xc,WHITE); Page | 24
  • 27. Program 6: Bresenham Circle Drawing Algorithm CODING: #include<conio.h> #include<graphics.h> #include<math.h> #include<iostream.h> void main() { int gd=DETECT,gm; initgraph(&gd,&gm,""); float x1,y1,f,xc,yc,r,t; cout<<"enter the x center y center and radius"; cin>>xc>>yc>>r; x1=0; y1=r; f=3-(2*r); while(x1<=y1) { if(f<=0) { f=f+6+4*x; x=x+1; } Page | 26
  • 29. Program 7: Mid Point Circle Drawing Algorithm CODING: #include<conio.h> #include<graphics.h> #include<math.h> #include<iostream.h> void main() { int gd=DETECT,gm; initgraph(&gd,&gm,""); float x1,y1,f,xc,yc,r; cout<<"MIDPOINT CIRCLEBY NEHA SHARMAn"; cout<<"enter the x center y center and radiusn"; cin>>xc>>yc>>r; x1=0; y1=r; f=1-r; while(x1<=y1) { if(f<=0) { f=f+3+2*x1; x1=x1+1; } Page | 28
  • 31. Program 8: DirectPolynomial Algorithm Of Ellipse Drawing CODING: #include<conio.h> #include<iostream.h> #include<graphics.h> #include<math.h> void main() { int gd=DETECT,gm; initgraph(&gd,&gm,""); float xc,yc,rx,ry,x1,y1,x2; cout<<"DIRECT ELLIPSE BY NEHA SHARMAn"; cout<<"enter xc,yc,x radius,y radiusn" ; cin>>xc>>yc>>rx>>ry; x1=0; x2=rx; while(x1<=x2) { y1=(ry/rx)*sqrt((rx*rx)-(x1*x1)); putpixel(x1+xc,y1+yc,WHITE); putpixel(x1+xc,-y1+yc,WHITE); putpixel(-x1+xc,-y1+yc,WHITE); Page | 30
  • 33. Program 9: Polar Ellipse Drawing Algorithm CODING: #include<conio.h> #include<iostream.h> #include<graphics.h> #include<math.h> void main() { int gd=DETECT,gm; initgraph(&gd,&gm,""); float xc,yc,rx,ry,t1,t2,x1,y1,x2; cout<<"POLAR ELLIPSE BY NEHA SHARMAn"; cout<<"enter xc,yc,x radius,y radiusn" ; cin>>xc>>yc>>rx>>ry; t1=0; t2=90; while(t1<=t2) { y1=ry*sin(t1); x1=rx*cos(t1); putpixel(x1+xc,y1+yc,WHITE); putpixel(x1+xc,-y1+yc,WHITE); putpixel(-x1+xc,-y1+yc,WHITE); Page | 32
  • 35. 10. Program To Draw Ellipse Using Midpoint Ellipse Algorithm Coding: #include<iostream.h> #include<conio.h> #include<graphics.h> #include<math.h> void main() { int gd=DETECT, gm; initgraph(&gd,&gm,""); float xc,yc,x,y,xr,yr,f; cout<<”tttt------------------------------------”; cout<<"ntttMID POINT ELLIPSE BY MOHITn"; cout<<”ntttt---------------------------------------”; cout<<"nEnter the coordinates xc,yc,xr ,yr"; cin>>xc>>yc>>xr>>yr; x=0; y=yr; f=(yr*yr)+(xr*xr)/4-(xr*xr)*yr; while(2*(yr*yr)*x<=2*(xr*xr)*y) { if(f<=0) { f=f+(3+(2*x))*(yr*yr); x++; putpixel(x+xc,y+yc,WHITE); putpixel(-x+xc,y+yc,WHITE); putpixel(-x+xc,-y+yc,WHITE); Page | 34