SlideShare a Scribd company logo
COMPUTER GRAPHICS -
DANCING DOLL
BASICS:
Computer graphics is an art of drawing pictures on computer screens with the help
of programming and algorithms. It involves computations, creation, and
manipulation of data. In other words, we can say that computer graphics is a
rendering tool for the generation and manipulation of images.
Application of Computer Graphics
1.Computer graphics user interfaces (GUIs). 2.Business presentation graphics
3.Cartography Weather Maps 4.Satellite Imaging Photo Enhancement
5.Medical Imaging 6.Engineering drawings
7.Typography 8.Architecture Art
9.Entertainment 10.Simulation and modeling
GRAPHICS.H
Used to draw different shapes, display text in different fonts, change colors and many more. Using functions of
graphics.h in Turbo C compiler you can make graphics programs, animations, projects, and games. You can draw
circles, lines, rectangles, bars and many other geometrical figures. You can change their colors using the available
functions and fill them. Following is a list of functions of graphics.h header file. Every function is discussed with the
arguments it needs, its description
GRAPHICS.H FUNCTIONS
arc bar bar3d circle
cleardevice closegraph drawpoly ellipse
fillellipse fillpoly floodfill getarccords
getbkcolor getcolor getdrivername getimage
getmaxcolor getmaxx getmaxy getpixel
getx gety graphdefaults grapherrormsg
imagesize line lineto linerel
moveto moverel outtext outtextxy
pieslice putimage putpixel rectangle
sector setbkcolor setcolor setfillstyle
setlinestyle settextstyle setviewport textheight textwidth
BASICS: LINE GENERATION ALGORITHM
In any 2-Dimensional plane if we connect two points (x0, y0) and (x1, y1), we get a line segment. But in the
case of computer graphics we can not directly join any two coordinate points, for that we should
CALCULATE INTERMEDIATE POINT’S COORDINATE and put a pixel for each intermediate point, of
the desired color with help of functions like putpixel(x, y, K) in C, where (x,y) is our co-ordinate and K
denotes some color
 DDAALGORITHM
 BRESENHAM’S LINE GENERATION
 MID-POINT ALGORITHM
DDA- LINE GENERATION ALGORITHM
Consider one point of the line as (X0,Y0) and the second point of the line as (X1,Y1).
// calculate dx , dy
dx = X1 - X0;
dy = Y1 - Y0;
// Depending upon absolute value of dx & dy
// choose number of steps to put pixel as
// steps = abs(dx) > abs(dy) ? abs(dx) : abs(dy)
steps = abs(dx) > abs(dy) ? abs(dx) : abs(dy);
// calculate increment in x & y for each steps
Xinc = dx / (float) steps;
Yinc = dy / (float) steps;
// Put pixel for each step
X = X0;
Y = Y0;
for (int i = 0; i <= steps; i++)
{
putpixel (X,Y,WHITE);
X += Xinc;
Y += Yinc;
}
BASICS: CIRCLE GENERATION ALGORITHM
 Drawing a circle on the screen is a little complex than drawing a line. There are two popular
algorithms for generating a circle: Bresenham’s Algorithm and Midpoint Circle Algorithm.
These algorithms are based on the idea of determining the subsequent points required to draw
the circle. Bresenham’s Algorithm:
Step 1 − Get the coordinates of the center of the circle and radius, and store them in
x, y, and R respectively. Set P=0 and Q=R.
Step 2 − Set decision parameter D = 3 – 2R.
Step 3 − Repeat through step-8 while P ≤ Q.
Step 4 − Call Draw Circle X,Y,P,QX,Y,P,Q.
Step 5 − Increment the value of P.
Step 6 − If D < 0 then D = D + 4P + 6.
Step 7 − Else Set R = R - 1, D = D + 4P−QP−Q + 10.
Step 8 − Call Draw Circle X,Y,P,Q.
putpixel (X + P, Y + Q)
putpixel (X - P, Y + Q)
putpixel (X + P, Y - Q)
putpixel (X - P, Y - Q)
putpixel (X + Q, Y + P)
putpixel (X - Q, Y + P)
putpixel (X + Q, Y - P)
putpixel (X - Q, Y - P)
BASICS: POLYGON FILLING
Polygon is an ordered list of vertices as shown in the following figure. For filling polygons with
particular colors, you need to determine the pixels falling on the border of the polygon and
those which fall inside the polygon.
Scan Line Algorithm
Flood Fill Algorithm
Boundary Fill Algorithm
4-Connected Polygon
8-Connected Polygon
Inside-outside Test : 1. Odd-Even Rule 2.Nonzero winding number rule
COMPUTER ANIMATION
The basic idea behind animation is to play back the recorded images at the rates fast enough to
fool the human eye into interpreting them as continuous motion. Animation can make a series of
dead images come alive. Animation can be used in many areas like entertainment, computer
aided-design, scientific visualization, training, education, e-commerce, and computer art.
Traditional Animation (frame by frame) : Key Framing
 A keyframe is a frame where we define changes in animation. Every frame is a keyframe when we
create frame by frame animation. When someone creates a 3D animation on a computer, they usually
don’t specify the exact position of any given object on every single frame. They create keyframes.
 Keyframes are important frames during which an object changes its size, direction, shape or other
properties. The computer then figures out all the in-between frames and saves an extreme amount of
time for the animator. The following illustrations depict the frames drawn by user and the frames
generated by computer.
DANCING DOLL: Visualization
Initial position
DANCING DOLL: CODE & OUTPUT
DANCING DOLL: DANCING DOLL

More Related Content

Similar to computer graphics-C/C++-dancingdollcode

Computer graphics
Computer graphicsComputer graphics
Computer graphics
Diksha Trivedi
 
raster algorithm.pdf
raster algorithm.pdfraster algorithm.pdf
raster algorithm.pdf
Mattupallipardhu
 
Cgm Lab Manual
Cgm Lab ManualCgm Lab Manual
Computer graphics notes watermark
Computer graphics notes watermarkComputer graphics notes watermark
Computer graphics notes watermark
RAJKIYA ENGINEERING COLLEGE, BANDA
 
Computer graphics notes
Computer graphics notesComputer graphics notes
Computer graphics notes
RAJKIYA ENGINEERING COLLEGE, BANDA
 
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdfCD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
RajJain516913
 
Computer Graphics involves technology to access. The Process transforms and p...
Computer Graphics involves technology to access. The Process transforms and p...Computer Graphics involves technology to access. The Process transforms and p...
Computer Graphics involves technology to access. The Process transforms and p...
ErNandiniDharne
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
amitsarda3
 
Unit 2
Unit 2Unit 2
Unit 2
ypnrao
 
4 CG_U1_M3_PPT_4 DDA.pptx
4 CG_U1_M3_PPT_4 DDA.pptx4 CG_U1_M3_PPT_4 DDA.pptx
4 CG_U1_M3_PPT_4 DDA.pptx
ssuser255bf1
 
Primitives
PrimitivesPrimitives
Computer Graphics Notes 2.pdf
Computer Graphics Notes 2.pdfComputer Graphics Notes 2.pdf
Computer Graphics Notes 2.pdf
AOUNHAIDER7
 
mini prjt
mini prjtmini prjt
Computer graphics
Computer graphics Computer graphics
Computer graphics
shafiq sangi
 
Computer Graphics Unit 1
Computer Graphics Unit 1Computer Graphics Unit 1
Computer Graphics Unit 1
aravindangc
 
CGR-Unit-1 Basics of Computer Graphics.pdf
CGR-Unit-1 Basics of Computer Graphics.pdfCGR-Unit-1 Basics of Computer Graphics.pdf
CGR-Unit-1 Basics of Computer Graphics.pdf
Rugved Collection
 
Computer graphics presentation
Computer graphics presentationComputer graphics presentation
Computer graphics presentation
LOKENDRA PRAJAPATI
 
Unit-1 basics of computer graphics
Unit-1 basics of computer graphicsUnit-1 basics of computer graphics
Unit-1 basics of computer graphics
Amol Gaikwad
 
Lab lecture 1 line_algo
Lab lecture 1 line_algoLab lecture 1 line_algo
Lab lecture 1 line_algo
simpleok
 
paper
paperpaper

Similar to computer graphics-C/C++-dancingdollcode (20)

Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
raster algorithm.pdf
raster algorithm.pdfraster algorithm.pdf
raster algorithm.pdf
 
Cgm Lab Manual
Cgm Lab ManualCgm Lab Manual
Cgm Lab Manual
 
Computer graphics notes watermark
Computer graphics notes watermarkComputer graphics notes watermark
Computer graphics notes watermark
 
Computer graphics notes
Computer graphics notesComputer graphics notes
Computer graphics notes
 
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdfCD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
 
Computer Graphics involves technology to access. The Process transforms and p...
Computer Graphics involves technology to access. The Process transforms and p...Computer Graphics involves technology to access. The Process transforms and p...
Computer Graphics involves technology to access. The Process transforms and p...
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
Unit 2
Unit 2Unit 2
Unit 2
 
4 CG_U1_M3_PPT_4 DDA.pptx
4 CG_U1_M3_PPT_4 DDA.pptx4 CG_U1_M3_PPT_4 DDA.pptx
4 CG_U1_M3_PPT_4 DDA.pptx
 
Primitives
PrimitivesPrimitives
Primitives
 
Computer Graphics Notes 2.pdf
Computer Graphics Notes 2.pdfComputer Graphics Notes 2.pdf
Computer Graphics Notes 2.pdf
 
mini prjt
mini prjtmini prjt
mini prjt
 
Computer graphics
Computer graphics Computer graphics
Computer graphics
 
Computer Graphics Unit 1
Computer Graphics Unit 1Computer Graphics Unit 1
Computer Graphics Unit 1
 
CGR-Unit-1 Basics of Computer Graphics.pdf
CGR-Unit-1 Basics of Computer Graphics.pdfCGR-Unit-1 Basics of Computer Graphics.pdf
CGR-Unit-1 Basics of Computer Graphics.pdf
 
Computer graphics presentation
Computer graphics presentationComputer graphics presentation
Computer graphics presentation
 
Unit-1 basics of computer graphics
Unit-1 basics of computer graphicsUnit-1 basics of computer graphics
Unit-1 basics of computer graphics
 
Lab lecture 1 line_algo
Lab lecture 1 line_algoLab lecture 1 line_algo
Lab lecture 1 line_algo
 
paper
paperpaper
paper
 

More from Bhavya Chawla

Version Control System - for Agile Software Project Management.
Version Control System - for Agile Software Project Management.Version Control System - for Agile Software Project Management.
Version Control System - for Agile Software Project Management.
Bhavya Chawla
 
Natural Language Processing
Natural Language ProcessingNatural Language Processing
Natural Language Processing
Bhavya Chawla
 
Ethical Hacking - sniffing
Ethical Hacking - sniffingEthical Hacking - sniffing
Ethical Hacking - sniffing
Bhavya Chawla
 
Employee Management System
Employee Management SystemEmployee Management System
Employee Management System
Bhavya Chawla
 
Sql introduction
Sql introductionSql introduction
Sql introduction
Bhavya Chawla
 
evolution of computers
 evolution of computers evolution of computers
evolution of computers
Bhavya Chawla
 
the generation of computers
the generation of computersthe generation of computers
the generation of computers
Bhavya Chawla
 

More from Bhavya Chawla (7)

Version Control System - for Agile Software Project Management.
Version Control System - for Agile Software Project Management.Version Control System - for Agile Software Project Management.
Version Control System - for Agile Software Project Management.
 
Natural Language Processing
Natural Language ProcessingNatural Language Processing
Natural Language Processing
 
Ethical Hacking - sniffing
Ethical Hacking - sniffingEthical Hacking - sniffing
Ethical Hacking - sniffing
 
Employee Management System
Employee Management SystemEmployee Management System
Employee Management System
 
Sql introduction
Sql introductionSql introduction
Sql introduction
 
evolution of computers
 evolution of computers evolution of computers
evolution of computers
 
the generation of computers
the generation of computersthe generation of computers
the generation of computers
 

Recently uploaded

Updated Limitations of Simplified Methods for Evaluating the Potential for Li...
Updated Limitations of Simplified Methods for Evaluating the Potential for Li...Updated Limitations of Simplified Methods for Evaluating the Potential for Li...
Updated Limitations of Simplified Methods for Evaluating the Potential for Li...
Robert Pyke
 
Indian Railway Signalling concepts and basics.pdf
Indian Railway Signalling concepts and basics.pdfIndian Railway Signalling concepts and basics.pdf
Indian Railway Signalling concepts and basics.pdf
princeshah76
 
Red Hat Enterprise Linux Administration 9.0 RH124 pdf
Red Hat Enterprise Linux Administration 9.0 RH124 pdfRed Hat Enterprise Linux Administration 9.0 RH124 pdf
Red Hat Enterprise Linux Administration 9.0 RH124 pdf
mdfkobir
 
FINE-TUNING OF SMALL/MEDIUM LLMS FOR BUSINESS QA ON STRUCTURED DATA
FINE-TUNING OF SMALL/MEDIUM LLMS FOR BUSINESS QA ON STRUCTURED DATAFINE-TUNING OF SMALL/MEDIUM LLMS FOR BUSINESS QA ON STRUCTURED DATA
FINE-TUNING OF SMALL/MEDIUM LLMS FOR BUSINESS QA ON STRUCTURED DATA
kevig
 
NOVEC 1230 Fire Suppression System Presentation
NOVEC 1230 Fire Suppression System PresentationNOVEC 1230 Fire Suppression System Presentation
NOVEC 1230 Fire Suppression System Presentation
miniruwan1
 
IE-469-Lecture-Notes-3IE-469-Lecture-Notes-3.pptx
IE-469-Lecture-Notes-3IE-469-Lecture-Notes-3.pptxIE-469-Lecture-Notes-3IE-469-Lecture-Notes-3.pptx
IE-469-Lecture-Notes-3IE-469-Lecture-Notes-3.pptx
BehairyAhmed2
 
ANATOMY OF SOA - Thomas Erl - Service Oriented Architecture
ANATOMY OF SOA - Thomas Erl - Service Oriented ArchitectureANATOMY OF SOA - Thomas Erl - Service Oriented Architecture
ANATOMY OF SOA - Thomas Erl - Service Oriented Architecture
Divya Rajasekar
 
1. DEE 1203 ELECTRICAL ENGINEERING DRAWING.pdf
1. DEE 1203 ELECTRICAL ENGINEERING DRAWING.pdf1. DEE 1203 ELECTRICAL ENGINEERING DRAWING.pdf
1. DEE 1203 ELECTRICAL ENGINEERING DRAWING.pdf
AsiimweJulius2
 
Disaster Management and Mitigation presentation
Disaster Management and Mitigation presentationDisaster Management and Mitigation presentation
Disaster Management and Mitigation presentation
RajaRamannaTarigoppu
 
Presentation slide on DESIGN AND FABRICATION OF MOBILE CONTROLLED DRAINAGE.pptx
Presentation slide on DESIGN AND FABRICATION OF MOBILE CONTROLLED DRAINAGE.pptxPresentation slide on DESIGN AND FABRICATION OF MOBILE CONTROLLED DRAINAGE.pptx
Presentation slide on DESIGN AND FABRICATION OF MOBILE CONTROLLED DRAINAGE.pptx
Er. Kushal Ghimire
 
The world of Technology Management MEM 814.pptx
The world of Technology Management MEM 814.pptxThe world of Technology Management MEM 814.pptx
The world of Technology Management MEM 814.pptx
engrasjadshahzad
 
Smart Factory – Starter Engagement Design.pptx
Smart Factory – Starter Engagement Design.pptxSmart Factory – Starter Engagement Design.pptx
Smart Factory – Starter Engagement Design.pptx
longngoai00
 
High Profile Girls Call Delhi 9711199171 Provide Best And Top Girl Service An...
High Profile Girls Call Delhi 9711199171 Provide Best And Top Girl Service An...High Profile Girls Call Delhi 9711199171 Provide Best And Top Girl Service An...
High Profile Girls Call Delhi 9711199171 Provide Best And Top Girl Service An...
janvikumar4133
 
The Control of Relative Humidity & Moisture Content in The Air
The Control of Relative Humidity & Moisture Content in The AirThe Control of Relative Humidity & Moisture Content in The Air
The Control of Relative Humidity & Moisture Content in The Air
Ashraf Ismail
 
JORC_Review_presentation. 2024 código jorcpdf
JORC_Review_presentation. 2024 código jorcpdfJORC_Review_presentation. 2024 código jorcpdf
JORC_Review_presentation. 2024 código jorcpdf
WilliamsNuezEspetia
 
If we're running two pumps, why aren't we getting twice as much flow? v.17
If we're running two pumps, why aren't we getting twice as much flow? v.17If we're running two pumps, why aren't we getting twice as much flow? v.17
If we're running two pumps, why aren't we getting twice as much flow? v.17
Brian Gongol
 
EAAP2023 : Durabilité et services écosystémiques de l'élevage ovin de montagne
EAAP2023 : Durabilité et services écosystémiques de l'élevage ovin de montagneEAAP2023 : Durabilité et services écosystémiques de l'élevage ovin de montagne
EAAP2023 : Durabilité et services écosystémiques de l'élevage ovin de montagne
idelewebmestre
 
LOCAL-BUDGET-CIRCULAR-NO-158-DATED-JULY-11-2024.pdf
LOCAL-BUDGET-CIRCULAR-NO-158-DATED-JULY-11-2024.pdfLOCAL-BUDGET-CIRCULAR-NO-158-DATED-JULY-11-2024.pdf
LOCAL-BUDGET-CIRCULAR-NO-158-DATED-JULY-11-2024.pdf
jellyjm
 
ISO 9001 - 2015 Quality Management Awareness.pdf
ISO 9001 - 2015 Quality Management Awareness.pdfISO 9001 - 2015 Quality Management Awareness.pdf
ISO 9001 - 2015 Quality Management Awareness.pdf
InfoDqms
 
Girls Call Mysore 000XX00000 Provide Best And Top Girl Service And No1 in City
Girls Call Mysore 000XX00000 Provide Best And Top Girl Service And No1 in CityGirls Call Mysore 000XX00000 Provide Best And Top Girl Service And No1 in City
Girls Call Mysore 000XX00000 Provide Best And Top Girl Service And No1 in City
rawankhanlove256
 

Recently uploaded (20)

Updated Limitations of Simplified Methods for Evaluating the Potential for Li...
Updated Limitations of Simplified Methods for Evaluating the Potential for Li...Updated Limitations of Simplified Methods for Evaluating the Potential for Li...
Updated Limitations of Simplified Methods for Evaluating the Potential for Li...
 
Indian Railway Signalling concepts and basics.pdf
Indian Railway Signalling concepts and basics.pdfIndian Railway Signalling concepts and basics.pdf
Indian Railway Signalling concepts and basics.pdf
 
Red Hat Enterprise Linux Administration 9.0 RH124 pdf
Red Hat Enterprise Linux Administration 9.0 RH124 pdfRed Hat Enterprise Linux Administration 9.0 RH124 pdf
Red Hat Enterprise Linux Administration 9.0 RH124 pdf
 
FINE-TUNING OF SMALL/MEDIUM LLMS FOR BUSINESS QA ON STRUCTURED DATA
FINE-TUNING OF SMALL/MEDIUM LLMS FOR BUSINESS QA ON STRUCTURED DATAFINE-TUNING OF SMALL/MEDIUM LLMS FOR BUSINESS QA ON STRUCTURED DATA
FINE-TUNING OF SMALL/MEDIUM LLMS FOR BUSINESS QA ON STRUCTURED DATA
 
NOVEC 1230 Fire Suppression System Presentation
NOVEC 1230 Fire Suppression System PresentationNOVEC 1230 Fire Suppression System Presentation
NOVEC 1230 Fire Suppression System Presentation
 
IE-469-Lecture-Notes-3IE-469-Lecture-Notes-3.pptx
IE-469-Lecture-Notes-3IE-469-Lecture-Notes-3.pptxIE-469-Lecture-Notes-3IE-469-Lecture-Notes-3.pptx
IE-469-Lecture-Notes-3IE-469-Lecture-Notes-3.pptx
 
ANATOMY OF SOA - Thomas Erl - Service Oriented Architecture
ANATOMY OF SOA - Thomas Erl - Service Oriented ArchitectureANATOMY OF SOA - Thomas Erl - Service Oriented Architecture
ANATOMY OF SOA - Thomas Erl - Service Oriented Architecture
 
1. DEE 1203 ELECTRICAL ENGINEERING DRAWING.pdf
1. DEE 1203 ELECTRICAL ENGINEERING DRAWING.pdf1. DEE 1203 ELECTRICAL ENGINEERING DRAWING.pdf
1. DEE 1203 ELECTRICAL ENGINEERING DRAWING.pdf
 
Disaster Management and Mitigation presentation
Disaster Management and Mitigation presentationDisaster Management and Mitigation presentation
Disaster Management and Mitigation presentation
 
Presentation slide on DESIGN AND FABRICATION OF MOBILE CONTROLLED DRAINAGE.pptx
Presentation slide on DESIGN AND FABRICATION OF MOBILE CONTROLLED DRAINAGE.pptxPresentation slide on DESIGN AND FABRICATION OF MOBILE CONTROLLED DRAINAGE.pptx
Presentation slide on DESIGN AND FABRICATION OF MOBILE CONTROLLED DRAINAGE.pptx
 
The world of Technology Management MEM 814.pptx
The world of Technology Management MEM 814.pptxThe world of Technology Management MEM 814.pptx
The world of Technology Management MEM 814.pptx
 
Smart Factory – Starter Engagement Design.pptx
Smart Factory – Starter Engagement Design.pptxSmart Factory – Starter Engagement Design.pptx
Smart Factory – Starter Engagement Design.pptx
 
High Profile Girls Call Delhi 9711199171 Provide Best And Top Girl Service An...
High Profile Girls Call Delhi 9711199171 Provide Best And Top Girl Service An...High Profile Girls Call Delhi 9711199171 Provide Best And Top Girl Service An...
High Profile Girls Call Delhi 9711199171 Provide Best And Top Girl Service An...
 
The Control of Relative Humidity & Moisture Content in The Air
The Control of Relative Humidity & Moisture Content in The AirThe Control of Relative Humidity & Moisture Content in The Air
The Control of Relative Humidity & Moisture Content in The Air
 
JORC_Review_presentation. 2024 código jorcpdf
JORC_Review_presentation. 2024 código jorcpdfJORC_Review_presentation. 2024 código jorcpdf
JORC_Review_presentation. 2024 código jorcpdf
 
If we're running two pumps, why aren't we getting twice as much flow? v.17
If we're running two pumps, why aren't we getting twice as much flow? v.17If we're running two pumps, why aren't we getting twice as much flow? v.17
If we're running two pumps, why aren't we getting twice as much flow? v.17
 
EAAP2023 : Durabilité et services écosystémiques de l'élevage ovin de montagne
EAAP2023 : Durabilité et services écosystémiques de l'élevage ovin de montagneEAAP2023 : Durabilité et services écosystémiques de l'élevage ovin de montagne
EAAP2023 : Durabilité et services écosystémiques de l'élevage ovin de montagne
 
LOCAL-BUDGET-CIRCULAR-NO-158-DATED-JULY-11-2024.pdf
LOCAL-BUDGET-CIRCULAR-NO-158-DATED-JULY-11-2024.pdfLOCAL-BUDGET-CIRCULAR-NO-158-DATED-JULY-11-2024.pdf
LOCAL-BUDGET-CIRCULAR-NO-158-DATED-JULY-11-2024.pdf
 
ISO 9001 - 2015 Quality Management Awareness.pdf
ISO 9001 - 2015 Quality Management Awareness.pdfISO 9001 - 2015 Quality Management Awareness.pdf
ISO 9001 - 2015 Quality Management Awareness.pdf
 
Girls Call Mysore 000XX00000 Provide Best And Top Girl Service And No1 in City
Girls Call Mysore 000XX00000 Provide Best And Top Girl Service And No1 in CityGirls Call Mysore 000XX00000 Provide Best And Top Girl Service And No1 in City
Girls Call Mysore 000XX00000 Provide Best And Top Girl Service And No1 in City
 

computer graphics-C/C++-dancingdollcode

  • 2. BASICS: Computer graphics is an art of drawing pictures on computer screens with the help of programming and algorithms. It involves computations, creation, and manipulation of data. In other words, we can say that computer graphics is a rendering tool for the generation and manipulation of images. Application of Computer Graphics 1.Computer graphics user interfaces (GUIs). 2.Business presentation graphics 3.Cartography Weather Maps 4.Satellite Imaging Photo Enhancement 5.Medical Imaging 6.Engineering drawings 7.Typography 8.Architecture Art 9.Entertainment 10.Simulation and modeling
  • 3. GRAPHICS.H Used to draw different shapes, display text in different fonts, change colors and many more. Using functions of graphics.h in Turbo C compiler you can make graphics programs, animations, projects, and games. You can draw circles, lines, rectangles, bars and many other geometrical figures. You can change their colors using the available functions and fill them. Following is a list of functions of graphics.h header file. Every function is discussed with the arguments it needs, its description GRAPHICS.H FUNCTIONS arc bar bar3d circle cleardevice closegraph drawpoly ellipse fillellipse fillpoly floodfill getarccords getbkcolor getcolor getdrivername getimage getmaxcolor getmaxx getmaxy getpixel getx gety graphdefaults grapherrormsg imagesize line lineto linerel moveto moverel outtext outtextxy pieslice putimage putpixel rectangle sector setbkcolor setcolor setfillstyle setlinestyle settextstyle setviewport textheight textwidth
  • 4. BASICS: LINE GENERATION ALGORITHM In any 2-Dimensional plane if we connect two points (x0, y0) and (x1, y1), we get a line segment. But in the case of computer graphics we can not directly join any two coordinate points, for that we should CALCULATE INTERMEDIATE POINT’S COORDINATE and put a pixel for each intermediate point, of the desired color with help of functions like putpixel(x, y, K) in C, where (x,y) is our co-ordinate and K denotes some color  DDAALGORITHM  BRESENHAM’S LINE GENERATION  MID-POINT ALGORITHM
  • 5. DDA- LINE GENERATION ALGORITHM Consider one point of the line as (X0,Y0) and the second point of the line as (X1,Y1). // calculate dx , dy dx = X1 - X0; dy = Y1 - Y0; // Depending upon absolute value of dx & dy // choose number of steps to put pixel as // steps = abs(dx) > abs(dy) ? abs(dx) : abs(dy) steps = abs(dx) > abs(dy) ? abs(dx) : abs(dy); // calculate increment in x & y for each steps Xinc = dx / (float) steps; Yinc = dy / (float) steps; // Put pixel for each step X = X0; Y = Y0; for (int i = 0; i <= steps; i++) { putpixel (X,Y,WHITE); X += Xinc; Y += Yinc; }
  • 6. BASICS: CIRCLE GENERATION ALGORITHM  Drawing a circle on the screen is a little complex than drawing a line. There are two popular algorithms for generating a circle: Bresenham’s Algorithm and Midpoint Circle Algorithm. These algorithms are based on the idea of determining the subsequent points required to draw the circle. Bresenham’s Algorithm: Step 1 − Get the coordinates of the center of the circle and radius, and store them in x, y, and R respectively. Set P=0 and Q=R. Step 2 − Set decision parameter D = 3 – 2R. Step 3 − Repeat through step-8 while P ≤ Q. Step 4 − Call Draw Circle X,Y,P,QX,Y,P,Q. Step 5 − Increment the value of P. Step 6 − If D < 0 then D = D + 4P + 6. Step 7 − Else Set R = R - 1, D = D + 4P−QP−Q + 10. Step 8 − Call Draw Circle X,Y,P,Q. putpixel (X + P, Y + Q) putpixel (X - P, Y + Q) putpixel (X + P, Y - Q) putpixel (X - P, Y - Q) putpixel (X + Q, Y + P) putpixel (X - Q, Y + P) putpixel (X + Q, Y - P) putpixel (X - Q, Y - P)
  • 7. BASICS: POLYGON FILLING Polygon is an ordered list of vertices as shown in the following figure. For filling polygons with particular colors, you need to determine the pixels falling on the border of the polygon and those which fall inside the polygon. Scan Line Algorithm Flood Fill Algorithm Boundary Fill Algorithm 4-Connected Polygon 8-Connected Polygon Inside-outside Test : 1. Odd-Even Rule 2.Nonzero winding number rule
  • 8. COMPUTER ANIMATION The basic idea behind animation is to play back the recorded images at the rates fast enough to fool the human eye into interpreting them as continuous motion. Animation can make a series of dead images come alive. Animation can be used in many areas like entertainment, computer aided-design, scientific visualization, training, education, e-commerce, and computer art. Traditional Animation (frame by frame) : Key Framing  A keyframe is a frame where we define changes in animation. Every frame is a keyframe when we create frame by frame animation. When someone creates a 3D animation on a computer, they usually don’t specify the exact position of any given object on every single frame. They create keyframes.  Keyframes are important frames during which an object changes its size, direction, shape or other properties. The computer then figures out all the in-between frames and saves an extreme amount of time for the animator. The following illustrations depict the frames drawn by user and the frames generated by computer.
  • 10. DANCING DOLL: CODE & OUTPUT