SlideShare a Scribd company logo
Computer Graphics Lab
Presented By : Tekendra Nath Yogi
Tekendranath@gmail.com
College Of Applied Business And Technology
Introduction
• Two modes of standard output device:
– Text mode:
• Set up display 25 lines of text with 80 characters per line.
• Characters are group of pixels
• But does not facilitates pixel manipulation
– Graphic mode:
• Facilitates pixel manipulation
• To work with graphics, c has various library functions.
• Graphics library functions are defined with in header file “graphics.h”
2By: Tekendra Nath Yogi2/9/2019
Contd….
• Representation of co-ordinates on computer screen:
– Each pixel has two coordinates (x,y):
• The horizontal coordinate corresponds to an X-coordinate
• The vertical coordinate corresponds to a Y coordinate
• origin of the coordinates of a computer screen is the upper left
corner.
3By: Tekendra Nath Yogi2/9/2019
Contd….
• IDE used:
– To create graphical applications we will use Turbo C++ 3.0 IDE and
the BGI library.
– BGI (Borland Graphics Interface) is a graphics library which provides
several functions which can be used to create graphical applications.
– The header file “graphics.h” will be used to access the functions of this
library.
4By: Tekendra Nath Yogi2/9/2019
Contd….
• General structure of graphics program in c:
5By: Tekendra Nath Yogi2/9/2019
Contd….
• Graphics mode initialization:
– initgraph() function is used
– Syntax: initgraph(&graphic_driver, &graphics_mode, “path_to_driver”);
– Graphics_driver is a variable which can be any valid identifier specifies the
graphics driver to be used.
– Graphic_mode is also a variable which can be any valid identifier is initialized
to the mode for the particular video adaptor to use.
– The third argument path_to_driver is a string constant the directories
containing .bgi and .char files.
– For automatic initialization DETECT constant is assigned to the graphic_driver
variable.
6By: Tekendra Nath Yogi2/9/2019
Contd….
• At the end of our graphics program, we have to unloads the
graphics drivers and sets the screen back to text mode by
calling closegraph() function.
7By: Tekendra Nath Yogi2/9/2019
Library functions
• Plotting and getting points:
– putpixel():
• plots a point with specified color
• syntax: putpixel(int x, int y, int color);
– getpixel( ):
• gets color of specified pixel
• Syntax : intger_variable = getpixel( int x, int y);
8By: Tekendra Nath Yogi2/9/2019
Contd….
• Example: Program to illustrate the point plotting on the screen
9By: Tekendra Nath Yogi2/9/2019
Contd….
• Example: program to illustrate the concept of getpixel()
function:
10By: Tekendra Nath Yogi2/9/2019
Contd….
• Color table: the colors available depends on the current
graphics driver and mode.
11By: Tekendra Nath Yogi2/9/2019
Contd….
• Changing drawing/foreground and background color:
– Setcolor():
• it change the current drawing color;
• Syntax: setcolor(int color);
– Setbkcolor():
• It change the background color
• Syntax: setbkcolor(int color);
12By: Tekendra Nath Yogi2/9/2019
Contd….
• Example
output1:
output2:
•
13By: Tekendra Nath Yogi2/9/2019
Contd….
• Drawing a line:
– line() function is used to draw line. We will give starting and ending
points of the line.
– Syntax: Line(x1, y1, x2, y2) // draw a line from (x1,y1) to (x2,y2).
14By: Tekendra Nath Yogi2/9/2019
Contd….
• Class work: Draw a line by using putpixel( ) function using for
loop.
15By: Tekendra Nath Yogi2/9/2019
Contd….
• Solution:
16By: Tekendra Nath Yogi2/9/2019
Contd….
• setlinestyle() function:
– sets the style for all lines drawn.
– setlinestyle(int linestyle, unsigned upattern, int thickness);
17By: Tekendra Nath Yogi2/9/2019
Contd….
• linestyle specifies in which of several styles subsequent lines
will be drawn (such as solid, dotted, centered, dashed).
18By: Tekendra Nath Yogi2/9/2019
Contd….
• upattern is a 16-bit pattern that applies only if linestyle is
USERBIT_LINE (4).
• thickness specifies whether the width of subsequent lines
drawn will be normal or thick
19By: Tekendra Nath Yogi2/9/2019
Contd….
• Example:
20By: Tekendra Nath Yogi2/9/2019
Contd….
• Draw circle in C graphics
– circle() function which draws a circle with center at (x, y) and given
radius.
– Syntax : circle(x, y, radius);
– where, (x, y) is center of the circle. 'radius' is the Radius of the circle.
– E.g.,
– Class work: change the color of circle outline.
21By: Tekendra Nath Yogi2/9/2019
Contd….
• Draw ellipse in C graphics:
– ellipse() function draws a ellipse.
– Syntax: ellipse(int x, int y, int start_angle, int end_angle, int x_radius, int y_radius),
– E.g.,
22By: Tekendra Nath Yogi2/9/2019
Contd….
• Drawing arc :
– The function arc( ) is used to draw a arc.
– Syntax: arc(int x, int y, int start_angle, int end_angle, int radius);
– E.g.,
23By: Tekendra Nath Yogi2/9/2019
Contd….
• Draw rectangle:
– The rectangle() function is used to draw rectangle
– Syntax: rectangle(int x1, int y1, int x2, int y2);
– E.g.,:
24By: Tekendra Nath Yogi2/9/2019
Contd….
• Drawing triangle:
– No function available, so draw triangle as a set of line.
– Idea: line(x1, y1, x2, y2);
line(x3,y3, x4, y4);
line(x5, y5, x6,y6);
25By: Tekendra Nath Yogi2/9/2019
Contd….
• Displaying a text in graphics mode:
– Outtext() function to display the string at the current
position
• Syntax: outtext(“Text”);
– Outtextxy()function to display at point(x,y);
• Syntax; outtextxy(x, y, “text”);
26By: Tekendra Nath Yogi2/9/2019
Contd….
• setfillstyle() and floodfill() in C:
– setfillstyle(): sets the current fill pattern and fill color.
• syntax: void setfillstyle(int pattern, int color)
– floodfill() : fill an enclosed area.
• Syntax: floodfill(int x, int y, int border_color)
27By: Tekendra Nath Yogi2/9/2019
Contd….
• Filling circle with certain pattern
28By: Tekendra Nath Yogi2/9/2019
Contd….
29By: Tekendra Nath Yogi2/9/2019
Contd….
• Moving circle with filled pattern in x-direction:
30By: Tekendra Nath Yogi2/9/2019
Contd….
DDAAlgorithm:
1. Input the two line endpoints (x1, y1) and (x2, y2).
2. Plot first point (x1, y1).
3. Calculate constants Δx = (x2- x1), and Δy =(y2-y1).
4. If |Δx| > |Δy|
then steps = |Δx|
else steps = |Δy|
5. Calculate XInc = Δx / steps and YInc = Δy / steps
6. for (k=0; k<steps; k++)
{
x =x+ xInc;
y =y+ yInc;
plot(ROUND(x), ROUND(y));
}
31By: Tekendra Nath Yogi2/9/2019
Contd….
32By: Tekendra Nath Yogi2/9/2019
Contd….
• OUTPUT:
33By: Tekendra Nath Yogi2/9/2019
Bresenham’s line algorithm
• Algorithm:
contd….
34By: Tekendra Nath Yogi2/9/2019
Contd….
• Contd…
contd….
35By: Tekendra Nath Yogi2/9/2019
Contd….
• Contd…
36By: Tekendra Nath Yogi2/9/2019
Contd….
37By: Tekendra Nath Yogi2/9/2019
Contd….
38By: Tekendra Nath Yogi2/9/2019
Contd….
39By: Tekendra Nath Yogi2/9/2019
Contd….
40By: Tekendra Nath Yogi2/9/2019
Contd….
41By: Tekendra Nath Yogi2/9/2019
Contd….
• Output:
42By: Tekendra Nath Yogi2/9/2019
Midpoint circle algorithm
1. Input radius r and circle center (xc, yc) and obtain the first point on the circumference of a
circle centered on the origin as
(x0,y0) = (0,r)
2. Calculate the initial value of the decision parameter as
P0 = 5/4 – r = 1-r
3. At each xk position, starting at k = 0, perform the following test:
If pk < 0, the next point along the circle centered on (0,0) is (xk+1,yk) and
Pk+1 = pk + 2xk+1 + 1
Otherwise, the next point along the circle is (xk+1,yK-1) and
Pk+1 = pk + 2xk+1 + 1 -2yk+1
Where 2xk+1 = 2xk + 2 and 2yk+1 = 2yk-2
4. Determine the symmetry points in the other seven octants.
5. Move each calculated pixel position (x,y) onto the circular path
centered on (xc,yc) and plot the co-ordinate values:
x = x + xc, y = y+yc
6. Repeat steps 3 through 5 until x ≥ y
43By: Tekendra Nath Yogi2/9/2019
Implementation
44By: Tekendra Nath Yogi2/9/2019
Contd….
45By: Tekendra Nath Yogi2/9/2019
Contd….
46By: Tekendra Nath Yogi2/9/2019
Contd….
• Output:
47By: Tekendra Nath Yogi2/9/2019
Midpoint Ellipse algorithm implementation
48By: Tekendra Nath Yogi2/9/2019
Contd….
49By: Tekendra Nath Yogi2/9/2019
Contd….
50By: Tekendra Nath Yogi2/9/2019
Contd….
• Output:
51By: Tekendra Nath Yogi2/9/2019
Area filling
• The process of painting defined area(such as rectangle , circle,
ellipse, etc) with specified color(solid-fill) or pattern(pattern-
fill).
• There are two basic approaches to area filling on raster
systems.
– Scan Fill
– Seed Fill (Boundary Fill, Flood Fill )
52By: Tekendra Nath Yogi2/9/2019
Contd….
53By: Tekendra Nath Yogi2/9/2019
Boundary Fill algorithm implementation
54By: Tekendra Nath Yogi2/9/2019
Contd….
55By: Tekendra Nath Yogi2/9/2019
flood fill algorithm implementation
56By: Tekendra Nath Yogi2/9/2019
Contd….
57By: Tekendra Nath Yogi2/9/2019
Contd….
58By: Tekendra Nath Yogi2/9/2019
Thank You !
59By: Tekendra Nath Yogi2/9/2019

More Related Content

What's hot

Numerical unit 1
Numerical unit 1Numerical unit 1
Numerical unit 1
Ankit Garg
 
Liang barsky Line Clipping Algorithm
Liang barsky Line Clipping AlgorithmLiang barsky Line Clipping Algorithm
Liang barsky Line Clipping Algorithm
Arvind Kumar
 
2D transformation (Computer Graphics)
2D transformation (Computer Graphics)2D transformation (Computer Graphics)
2D transformation (Computer Graphics)
Timbal Mayank
 
COMPUTER GRAPHICS LAB MANUAL
COMPUTER GRAPHICS LAB MANUALCOMPUTER GRAPHICS LAB MANUAL
COMPUTER GRAPHICS LAB MANUAL
Vivek Kumar Sinha
 
Graphics practical lab manual
Graphics practical lab manualGraphics practical lab manual
Graphics practical lab manual
Vivek Kumar Sinha
 
Monitors & workstation,Donald ch-2
Monitors & workstation,Donald ch-2Monitors & workstation,Donald ch-2
Monitors & workstation,Donald ch-2
Iftikhar Ahmad
 
ATTRIBUTES OF OUTPUT PRIMITIVES IN COMPUTER GRAPHICS
ATTRIBUTES OF OUTPUT PRIMITIVES IN COMPUTER GRAPHICSATTRIBUTES OF OUTPUT PRIMITIVES IN COMPUTER GRAPHICS
ATTRIBUTES OF OUTPUT PRIMITIVES IN COMPUTER GRAPHICS
nehrurevathy
 
Mid point circle algorithm
Mid point circle algorithmMid point circle algorithm
Mid point circle algorithm
Mani Kanth
 
Computer Graphics
Computer GraphicsComputer Graphics
Computer Graphics
Ankur Soni
 
B. SC CSIT Computer Graphics Unit 2 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 2 By Tekendra Nath YogiB. SC CSIT Computer Graphics Unit 2 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 2 By Tekendra Nath Yogi
Tekendra Nath Yogi
 
Viewing transformation
Viewing transformationViewing transformation
Viewing transformationUdayan Gupta
 
Graphics software and standards
Graphics software and standardsGraphics software and standards
Graphics software and standards
Mani Kanth
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
kparthjadhav
 
Raster scan system & random scan system
Raster scan system & random scan systemRaster scan system & random scan system
Raster scan system & random scan system
shalinikarunakaran1
 
B. SC CSIT Computer Graphics Unit 4 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 4 By Tekendra Nath YogiB. SC CSIT Computer Graphics Unit 4 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 4 By Tekendra Nath Yogi
Tekendra Nath Yogi
 
Cohen sutherland line clipping
Cohen sutherland line clippingCohen sutherland line clipping
Cohen sutherland line clipping
Mani Kanth
 
Mid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer GraphicsMid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer Graphics
Drishti Bhalla
 
3 d transformation
3 d transformation3 d transformation
3 d transformation
Pooja Dixit
 
Mid-Point Cirle Drawing Algorithm
Mid-Point Cirle Drawing AlgorithmMid-Point Cirle Drawing Algorithm
Mid-Point Cirle Drawing AlgorithmNeha Kaurav
 

What's hot (20)

Numerical unit 1
Numerical unit 1Numerical unit 1
Numerical unit 1
 
Bresenham circle
Bresenham circleBresenham circle
Bresenham circle
 
Liang barsky Line Clipping Algorithm
Liang barsky Line Clipping AlgorithmLiang barsky Line Clipping Algorithm
Liang barsky Line Clipping Algorithm
 
2D transformation (Computer Graphics)
2D transformation (Computer Graphics)2D transformation (Computer Graphics)
2D transformation (Computer Graphics)
 
COMPUTER GRAPHICS LAB MANUAL
COMPUTER GRAPHICS LAB MANUALCOMPUTER GRAPHICS LAB MANUAL
COMPUTER GRAPHICS LAB MANUAL
 
Graphics practical lab manual
Graphics practical lab manualGraphics practical lab manual
Graphics practical lab manual
 
Monitors & workstation,Donald ch-2
Monitors & workstation,Donald ch-2Monitors & workstation,Donald ch-2
Monitors & workstation,Donald ch-2
 
ATTRIBUTES OF OUTPUT PRIMITIVES IN COMPUTER GRAPHICS
ATTRIBUTES OF OUTPUT PRIMITIVES IN COMPUTER GRAPHICSATTRIBUTES OF OUTPUT PRIMITIVES IN COMPUTER GRAPHICS
ATTRIBUTES OF OUTPUT PRIMITIVES IN COMPUTER GRAPHICS
 
Mid point circle algorithm
Mid point circle algorithmMid point circle algorithm
Mid point circle algorithm
 
Computer Graphics
Computer GraphicsComputer Graphics
Computer Graphics
 
B. SC CSIT Computer Graphics Unit 2 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 2 By Tekendra Nath YogiB. SC CSIT Computer Graphics Unit 2 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 2 By Tekendra Nath Yogi
 
Viewing transformation
Viewing transformationViewing transformation
Viewing transformation
 
Graphics software and standards
Graphics software and standardsGraphics software and standards
Graphics software and standards
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
 
Raster scan system & random scan system
Raster scan system & random scan systemRaster scan system & random scan system
Raster scan system & random scan system
 
B. SC CSIT Computer Graphics Unit 4 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 4 By Tekendra Nath YogiB. SC CSIT Computer Graphics Unit 4 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 4 By Tekendra Nath Yogi
 
Cohen sutherland line clipping
Cohen sutherland line clippingCohen sutherland line clipping
Cohen sutherland line clipping
 
Mid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer GraphicsMid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer Graphics
 
3 d transformation
3 d transformation3 d transformation
3 d transformation
 
Mid-Point Cirle Drawing Algorithm
Mid-Point Cirle Drawing AlgorithmMid-Point Cirle Drawing Algorithm
Mid-Point Cirle Drawing Algorithm
 

Similar to B. SC CSIT Computer Graphics Lab By Tekendra Nath Yogi

Primitives
PrimitivesPrimitives
We are restricted from importing cv2 numpy stats and other.pdf
We are restricted from importing cv2 numpy stats and other.pdfWe are restricted from importing cv2 numpy stats and other.pdf
We are restricted from importing cv2 numpy stats and other.pdf
DARSHANACHARYA13
 
computer graphics-C/C++-dancingdollcode
computer graphics-C/C++-dancingdollcodecomputer graphics-C/C++-dancingdollcode
computer graphics-C/C++-dancingdollcode
Bhavya Chawla
 
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdfCD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
RajJain516913
 
Trident International Graphics Workshop 2014 1/5
Trident International Graphics Workshop 2014 1/5Trident International Graphics Workshop 2014 1/5
Trident International Graphics Workshop 2014 1/5
Takao Wada
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
Ankit Kumar
 
Cad notes - ENGINEERING DRAWING - RGPV,BHOPAL
Cad notes - ENGINEERING DRAWING - RGPV,BHOPALCad notes - ENGINEERING DRAWING - RGPV,BHOPAL
Cad notes - ENGINEERING DRAWING - RGPV,BHOPAL
Abhishek Kandare
 
Computer graphics
Computer graphicsComputer graphics
Computer graphicsamitsarda3
 
Beginning direct3d gameprogramming01_thehistoryofdirect3dgraphics_20160407_ji...
Beginning direct3d gameprogramming01_thehistoryofdirect3dgraphics_20160407_ji...Beginning direct3d gameprogramming01_thehistoryofdirect3dgraphics_20160407_ji...
Beginning direct3d gameprogramming01_thehistoryofdirect3dgraphics_20160407_ji...
JinTaek Seo
 
Computer graphics practical(jainam)
Computer graphics practical(jainam)Computer graphics practical(jainam)
Computer graphics practical(jainam)
JAINAM KAPADIYA
 
Introducing AlloyUI DiagramBuilder
Introducing AlloyUI DiagramBuilderIntroducing AlloyUI DiagramBuilder
Introducing AlloyUI DiagramBuilderEduardo Lundgren
 
Computer Graphics Unit 1
Computer Graphics Unit 1Computer Graphics Unit 1
Computer Graphics Unit 1
aravindangc
 
JDK and AWT
JDK and AWTJDK and AWT
Computer graphics
Computer graphics Computer graphics
Computer graphics
shafiq sangi
 
3rd Semester Computer Science and Engineering (ACU) Question papers
3rd Semester Computer Science and Engineering  (ACU) Question papers3rd Semester Computer Science and Engineering  (ACU) Question papers
3rd Semester Computer Science and Engineering (ACU) Question papers
BGS Institute of Technology, Adichunchanagiri University (ACU)
 

Similar to B. SC CSIT Computer Graphics Lab By Tekendra Nath Yogi (20)

Primitives
PrimitivesPrimitives
Primitives
 
Cg lab cse-v (1) (1)
Cg lab cse-v (1) (1)Cg lab cse-v (1) (1)
Cg lab cse-v (1) (1)
 
Cad notes
Cad notesCad notes
Cad notes
 
We are restricted from importing cv2 numpy stats and other.pdf
We are restricted from importing cv2 numpy stats and other.pdfWe are restricted from importing cv2 numpy stats and other.pdf
We are restricted from importing cv2 numpy stats and other.pdf
 
computer graphics-C/C++-dancingdollcode
computer graphics-C/C++-dancingdollcodecomputer graphics-C/C++-dancingdollcode
computer graphics-C/C++-dancingdollcode
 
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdfCD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
 
CAD
CADCAD
CAD
 
Cad notes
Cad notesCad notes
Cad notes
 
Trident International Graphics Workshop 2014 1/5
Trident International Graphics Workshop 2014 1/5Trident International Graphics Workshop 2014 1/5
Trident International Graphics Workshop 2014 1/5
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
 
Cad notes - ENGINEERING DRAWING - RGPV,BHOPAL
Cad notes - ENGINEERING DRAWING - RGPV,BHOPALCad notes - ENGINEERING DRAWING - RGPV,BHOPAL
Cad notes - ENGINEERING DRAWING - RGPV,BHOPAL
 
Cgm Lab Manual
Cgm Lab ManualCgm Lab Manual
Cgm Lab Manual
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
Beginning direct3d gameprogramming01_thehistoryofdirect3dgraphics_20160407_ji...
Beginning direct3d gameprogramming01_thehistoryofdirect3dgraphics_20160407_ji...Beginning direct3d gameprogramming01_thehistoryofdirect3dgraphics_20160407_ji...
Beginning direct3d gameprogramming01_thehistoryofdirect3dgraphics_20160407_ji...
 
Computer graphics practical(jainam)
Computer graphics practical(jainam)Computer graphics practical(jainam)
Computer graphics practical(jainam)
 
Introducing AlloyUI DiagramBuilder
Introducing AlloyUI DiagramBuilderIntroducing AlloyUI DiagramBuilder
Introducing AlloyUI DiagramBuilder
 
Computer Graphics Unit 1
Computer Graphics Unit 1Computer Graphics Unit 1
Computer Graphics Unit 1
 
JDK and AWT
JDK and AWTJDK and AWT
JDK and AWT
 
Computer graphics
Computer graphics Computer graphics
Computer graphics
 
3rd Semester Computer Science and Engineering (ACU) Question papers
3rd Semester Computer Science and Engineering  (ACU) Question papers3rd Semester Computer Science and Engineering  (ACU) Question papers
3rd Semester Computer Science and Engineering (ACU) Question papers
 

More from Tekendra Nath Yogi

Unit9:Expert System
Unit9:Expert SystemUnit9:Expert System
Unit9:Expert System
Tekendra Nath Yogi
 
Unit7: Production System
Unit7: Production SystemUnit7: Production System
Unit7: Production System
Tekendra Nath Yogi
 
Unit8: Uncertainty in AI
Unit8: Uncertainty in AIUnit8: Uncertainty in AI
Unit8: Uncertainty in AI
Tekendra Nath Yogi
 
Unit5: Learning
Unit5: LearningUnit5: Learning
Unit5: Learning
Tekendra Nath Yogi
 
Unit4: Knowledge Representation
Unit4: Knowledge RepresentationUnit4: Knowledge Representation
Unit4: Knowledge Representation
Tekendra Nath Yogi
 
Unit3:Informed and Uninformed search
Unit3:Informed and Uninformed searchUnit3:Informed and Uninformed search
Unit3:Informed and Uninformed search
Tekendra Nath Yogi
 
Unit2: Agents and Environment
Unit2: Agents and EnvironmentUnit2: Agents and Environment
Unit2: Agents and Environment
Tekendra Nath Yogi
 
Unit1: Introduction to AI
Unit1: Introduction to AIUnit1: Introduction to AI
Unit1: Introduction to AI
Tekendra Nath Yogi
 
Unit 6: Application of AI
Unit 6: Application of AIUnit 6: Application of AI
Unit 6: Application of AI
Tekendra Nath Yogi
 
Unit10
Unit10Unit10
Unit9
Unit9Unit9
Unit8
Unit8Unit8
Unit7
Unit7Unit7
BIM Data Mining Unit5 by Tekendra Nath Yogi
 BIM Data Mining Unit5 by Tekendra Nath Yogi BIM Data Mining Unit5 by Tekendra Nath Yogi
BIM Data Mining Unit5 by Tekendra Nath Yogi
Tekendra Nath Yogi
 
BIM Data Mining Unit4 by Tekendra Nath Yogi
 BIM Data Mining Unit4 by Tekendra Nath Yogi BIM Data Mining Unit4 by Tekendra Nath Yogi
BIM Data Mining Unit4 by Tekendra Nath Yogi
Tekendra Nath Yogi
 
BIM Data Mining Unit3 by Tekendra Nath Yogi
 BIM Data Mining Unit3 by Tekendra Nath Yogi BIM Data Mining Unit3 by Tekendra Nath Yogi
BIM Data Mining Unit3 by Tekendra Nath Yogi
Tekendra Nath Yogi
 
BIM Data Mining Unit2 by Tekendra Nath Yogi
 BIM Data Mining Unit2 by Tekendra Nath Yogi BIM Data Mining Unit2 by Tekendra Nath Yogi
BIM Data Mining Unit2 by Tekendra Nath Yogi
Tekendra Nath Yogi
 
BIM Data Mining Unit1 by Tekendra Nath Yogi
 BIM Data Mining Unit1 by Tekendra Nath Yogi BIM Data Mining Unit1 by Tekendra Nath Yogi
BIM Data Mining Unit1 by Tekendra Nath Yogi
Tekendra Nath Yogi
 
Unit6
Unit6Unit6
B. SC CSIT Computer Graphics Unit 5 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 5 By Tekendra Nath YogiB. SC CSIT Computer Graphics Unit 5 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 5 By Tekendra Nath Yogi
Tekendra Nath Yogi
 

More from Tekendra Nath Yogi (20)

Unit9:Expert System
Unit9:Expert SystemUnit9:Expert System
Unit9:Expert System
 
Unit7: Production System
Unit7: Production SystemUnit7: Production System
Unit7: Production System
 
Unit8: Uncertainty in AI
Unit8: Uncertainty in AIUnit8: Uncertainty in AI
Unit8: Uncertainty in AI
 
Unit5: Learning
Unit5: LearningUnit5: Learning
Unit5: Learning
 
Unit4: Knowledge Representation
Unit4: Knowledge RepresentationUnit4: Knowledge Representation
Unit4: Knowledge Representation
 
Unit3:Informed and Uninformed search
Unit3:Informed and Uninformed searchUnit3:Informed and Uninformed search
Unit3:Informed and Uninformed search
 
Unit2: Agents and Environment
Unit2: Agents and EnvironmentUnit2: Agents and Environment
Unit2: Agents and Environment
 
Unit1: Introduction to AI
Unit1: Introduction to AIUnit1: Introduction to AI
Unit1: Introduction to AI
 
Unit 6: Application of AI
Unit 6: Application of AIUnit 6: Application of AI
Unit 6: Application of AI
 
Unit10
Unit10Unit10
Unit10
 
Unit9
Unit9Unit9
Unit9
 
Unit8
Unit8Unit8
Unit8
 
Unit7
Unit7Unit7
Unit7
 
BIM Data Mining Unit5 by Tekendra Nath Yogi
 BIM Data Mining Unit5 by Tekendra Nath Yogi BIM Data Mining Unit5 by Tekendra Nath Yogi
BIM Data Mining Unit5 by Tekendra Nath Yogi
 
BIM Data Mining Unit4 by Tekendra Nath Yogi
 BIM Data Mining Unit4 by Tekendra Nath Yogi BIM Data Mining Unit4 by Tekendra Nath Yogi
BIM Data Mining Unit4 by Tekendra Nath Yogi
 
BIM Data Mining Unit3 by Tekendra Nath Yogi
 BIM Data Mining Unit3 by Tekendra Nath Yogi BIM Data Mining Unit3 by Tekendra Nath Yogi
BIM Data Mining Unit3 by Tekendra Nath Yogi
 
BIM Data Mining Unit2 by Tekendra Nath Yogi
 BIM Data Mining Unit2 by Tekendra Nath Yogi BIM Data Mining Unit2 by Tekendra Nath Yogi
BIM Data Mining Unit2 by Tekendra Nath Yogi
 
BIM Data Mining Unit1 by Tekendra Nath Yogi
 BIM Data Mining Unit1 by Tekendra Nath Yogi BIM Data Mining Unit1 by Tekendra Nath Yogi
BIM Data Mining Unit1 by Tekendra Nath Yogi
 
Unit6
Unit6Unit6
Unit6
 
B. SC CSIT Computer Graphics Unit 5 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 5 By Tekendra Nath YogiB. SC CSIT Computer Graphics Unit 5 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 5 By Tekendra Nath Yogi
 

Recently uploaded

Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
Celine George
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 

Recently uploaded (20)

Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 

B. SC CSIT Computer Graphics Lab By Tekendra Nath Yogi

  • 1. Computer Graphics Lab Presented By : Tekendra Nath Yogi Tekendranath@gmail.com College Of Applied Business And Technology
  • 2. Introduction • Two modes of standard output device: – Text mode: • Set up display 25 lines of text with 80 characters per line. • Characters are group of pixels • But does not facilitates pixel manipulation – Graphic mode: • Facilitates pixel manipulation • To work with graphics, c has various library functions. • Graphics library functions are defined with in header file “graphics.h” 2By: Tekendra Nath Yogi2/9/2019
  • 3. Contd…. • Representation of co-ordinates on computer screen: – Each pixel has two coordinates (x,y): • The horizontal coordinate corresponds to an X-coordinate • The vertical coordinate corresponds to a Y coordinate • origin of the coordinates of a computer screen is the upper left corner. 3By: Tekendra Nath Yogi2/9/2019
  • 4. Contd…. • IDE used: – To create graphical applications we will use Turbo C++ 3.0 IDE and the BGI library. – BGI (Borland Graphics Interface) is a graphics library which provides several functions which can be used to create graphical applications. – The header file “graphics.h” will be used to access the functions of this library. 4By: Tekendra Nath Yogi2/9/2019
  • 5. Contd…. • General structure of graphics program in c: 5By: Tekendra Nath Yogi2/9/2019
  • 6. Contd…. • Graphics mode initialization: – initgraph() function is used – Syntax: initgraph(&graphic_driver, &graphics_mode, “path_to_driver”); – Graphics_driver is a variable which can be any valid identifier specifies the graphics driver to be used. – Graphic_mode is also a variable which can be any valid identifier is initialized to the mode for the particular video adaptor to use. – The third argument path_to_driver is a string constant the directories containing .bgi and .char files. – For automatic initialization DETECT constant is assigned to the graphic_driver variable. 6By: Tekendra Nath Yogi2/9/2019
  • 7. Contd…. • At the end of our graphics program, we have to unloads the graphics drivers and sets the screen back to text mode by calling closegraph() function. 7By: Tekendra Nath Yogi2/9/2019
  • 8. Library functions • Plotting and getting points: – putpixel(): • plots a point with specified color • syntax: putpixel(int x, int y, int color); – getpixel( ): • gets color of specified pixel • Syntax : intger_variable = getpixel( int x, int y); 8By: Tekendra Nath Yogi2/9/2019
  • 9. Contd…. • Example: Program to illustrate the point plotting on the screen 9By: Tekendra Nath Yogi2/9/2019
  • 10. Contd…. • Example: program to illustrate the concept of getpixel() function: 10By: Tekendra Nath Yogi2/9/2019
  • 11. Contd…. • Color table: the colors available depends on the current graphics driver and mode. 11By: Tekendra Nath Yogi2/9/2019
  • 12. Contd…. • Changing drawing/foreground and background color: – Setcolor(): • it change the current drawing color; • Syntax: setcolor(int color); – Setbkcolor(): • It change the background color • Syntax: setbkcolor(int color); 12By: Tekendra Nath Yogi2/9/2019
  • 14. Contd…. • Drawing a line: – line() function is used to draw line. We will give starting and ending points of the line. – Syntax: Line(x1, y1, x2, y2) // draw a line from (x1,y1) to (x2,y2). 14By: Tekendra Nath Yogi2/9/2019
  • 15. Contd…. • Class work: Draw a line by using putpixel( ) function using for loop. 15By: Tekendra Nath Yogi2/9/2019
  • 17. Contd…. • setlinestyle() function: – sets the style for all lines drawn. – setlinestyle(int linestyle, unsigned upattern, int thickness); 17By: Tekendra Nath Yogi2/9/2019
  • 18. Contd…. • linestyle specifies in which of several styles subsequent lines will be drawn (such as solid, dotted, centered, dashed). 18By: Tekendra Nath Yogi2/9/2019
  • 19. Contd…. • upattern is a 16-bit pattern that applies only if linestyle is USERBIT_LINE (4). • thickness specifies whether the width of subsequent lines drawn will be normal or thick 19By: Tekendra Nath Yogi2/9/2019
  • 21. Contd…. • Draw circle in C graphics – circle() function which draws a circle with center at (x, y) and given radius. – Syntax : circle(x, y, radius); – where, (x, y) is center of the circle. 'radius' is the Radius of the circle. – E.g., – Class work: change the color of circle outline. 21By: Tekendra Nath Yogi2/9/2019
  • 22. Contd…. • Draw ellipse in C graphics: – ellipse() function draws a ellipse. – Syntax: ellipse(int x, int y, int start_angle, int end_angle, int x_radius, int y_radius), – E.g., 22By: Tekendra Nath Yogi2/9/2019
  • 23. Contd…. • Drawing arc : – The function arc( ) is used to draw a arc. – Syntax: arc(int x, int y, int start_angle, int end_angle, int radius); – E.g., 23By: Tekendra Nath Yogi2/9/2019
  • 24. Contd…. • Draw rectangle: – The rectangle() function is used to draw rectangle – Syntax: rectangle(int x1, int y1, int x2, int y2); – E.g.,: 24By: Tekendra Nath Yogi2/9/2019
  • 25. Contd…. • Drawing triangle: – No function available, so draw triangle as a set of line. – Idea: line(x1, y1, x2, y2); line(x3,y3, x4, y4); line(x5, y5, x6,y6); 25By: Tekendra Nath Yogi2/9/2019
  • 26. Contd…. • Displaying a text in graphics mode: – Outtext() function to display the string at the current position • Syntax: outtext(“Text”); – Outtextxy()function to display at point(x,y); • Syntax; outtextxy(x, y, “text”); 26By: Tekendra Nath Yogi2/9/2019
  • 27. Contd…. • setfillstyle() and floodfill() in C: – setfillstyle(): sets the current fill pattern and fill color. • syntax: void setfillstyle(int pattern, int color) – floodfill() : fill an enclosed area. • Syntax: floodfill(int x, int y, int border_color) 27By: Tekendra Nath Yogi2/9/2019
  • 28. Contd…. • Filling circle with certain pattern 28By: Tekendra Nath Yogi2/9/2019
  • 30. Contd…. • Moving circle with filled pattern in x-direction: 30By: Tekendra Nath Yogi2/9/2019
  • 31. Contd…. DDAAlgorithm: 1. Input the two line endpoints (x1, y1) and (x2, y2). 2. Plot first point (x1, y1). 3. Calculate constants Δx = (x2- x1), and Δy =(y2-y1). 4. If |Δx| > |Δy| then steps = |Δx| else steps = |Δy| 5. Calculate XInc = Δx / steps and YInc = Δy / steps 6. for (k=0; k<steps; k++) { x =x+ xInc; y =y+ yInc; plot(ROUND(x), ROUND(y)); } 31By: Tekendra Nath Yogi2/9/2019
  • 34. Bresenham’s line algorithm • Algorithm: contd…. 34By: Tekendra Nath Yogi2/9/2019
  • 43. Midpoint circle algorithm 1. Input radius r and circle center (xc, yc) and obtain the first point on the circumference of a circle centered on the origin as (x0,y0) = (0,r) 2. Calculate the initial value of the decision parameter as P0 = 5/4 – r = 1-r 3. At each xk position, starting at k = 0, perform the following test: If pk < 0, the next point along the circle centered on (0,0) is (xk+1,yk) and Pk+1 = pk + 2xk+1 + 1 Otherwise, the next point along the circle is (xk+1,yK-1) and Pk+1 = pk + 2xk+1 + 1 -2yk+1 Where 2xk+1 = 2xk + 2 and 2yk+1 = 2yk-2 4. Determine the symmetry points in the other seven octants. 5. Move each calculated pixel position (x,y) onto the circular path centered on (xc,yc) and plot the co-ordinate values: x = x + xc, y = y+yc 6. Repeat steps 3 through 5 until x ≥ y 43By: Tekendra Nath Yogi2/9/2019
  • 48. Midpoint Ellipse algorithm implementation 48By: Tekendra Nath Yogi2/9/2019
  • 52. Area filling • The process of painting defined area(such as rectangle , circle, ellipse, etc) with specified color(solid-fill) or pattern(pattern- fill). • There are two basic approaches to area filling on raster systems. – Scan Fill – Seed Fill (Boundary Fill, Flood Fill ) 52By: Tekendra Nath Yogi2/9/2019
  • 54. Boundary Fill algorithm implementation 54By: Tekendra Nath Yogi2/9/2019
  • 56. flood fill algorithm implementation 56By: Tekendra Nath Yogi2/9/2019
  • 59. Thank You ! 59By: Tekendra Nath Yogi2/9/2019