SlideShare uma empresa Scribd logo
1 de 13
Baixar para ler offline
Computer Graphics Lab
By Priya Goyal
How to run the graphics program in Turbo C++
• Open turbo C++
• Click on Option => Linker => Library
• Click on Graphics(mark it as ‘X’)
• Click on OK
Now you can run your graphics programs.
Basic functions to draw shapes in graphics
Shape Function syntax
pixel Draw a pixel Putpixel (X1,Y1,Color)
Line Draw a line Line(X1,Y1,X2,Y2)
Rectangle Draw a rectangle Rectangle(Left,Top,Right,Bottom)
Circle Draw a circle Circle(X,Y,Radius)
Ellipse Draw a ellipse Ellipse(X1,Y1,0,360,XaxisRadius,YaxisRadius)
Arc Draw a arc Arc(X1,Y1,StartingAngle,EndingAngle,Radius)
Bar Draw a filled rectangle Bar(Left,Top,Right,Bottom)
Bar3d Draw a filled 3d rectangle Bar3d(Left,Top,Right,Bottom,depth,topflag)
**topflag will be 0 or 1**
Here X1=distance of first point of shape from X axis,
X2=Distance of last point of shape from X axis
Here Y1=distance of first point of shape from Y axis,
Y2=Distance of last point of shape from Y axis
Structure of graphics program
#include<graphics.h>
#include<stdio.h>
#include<conio.h>
void main( )
{
int gd = DETECT, gm;
initgraph(&gd, &gm, "C:TCBGI");
……………………
…………………….
getch( );
closegraph( );
}
Location of BGI folder, where
display files are saved. Write the
location of (C:-TC-BGI)
Initialization of
graph
Draw a Pixel
#include<graphics.h>
#include<stdio.h>
#include<conio.h>
void main( )
{
int gd = DETECT, gm;
initgraph(&gd, &gm, "C:TCBGI");
Putpixel(100,100,RED)
getch( );
closegraph( );
}
Putpixel(X1,Y1,Color)
Draw a line
#include<graphics.h>
#include<stdio.h>
#include<conio.h>
void main( )
{
int gd = DETECT, gm;
initgraph(&gd, &gm, "C:TCBGI");
Line(100,100,200,200)
getch( );
closegraph( );
}
Line(X1,Y1,X2,Y2)
Draw a Rectangle
#include<graphics.h>
#include<stdio.h>
#include<conio.h>
void main( )
{
int gd = DETECT, gm;
initgraph(&gd, &gm, "C:TCBGI");
Rectangle(100,100,200,200)
getch( );
closegraph( );
}
rectangle(X1,Y1,X2,Y2)
Draw a circle
#include<graphics.h>
#include<stdio.h>
#include<conio.h>
void main( )
{
int gd = DETECT, gm;
initgraph(&gd, &gm, "C:TCBGI");
Circle(100,100,10)
getch( );
closegraph( );
}
circle(X1,Y1,radius)
Draw an ellipse
#include<graphics.h>
#include<stdio.h>
#include<conio.h>
void main( )
{
int gd = DETECT, gm;
initgraph(&gd, &gm, "C:TCBGI");
ellipse(100,100,0,360,20,10);
getch( );
closegraph( );
}
ellipse(x1,y1,0,360,xAxisRadius,yAxisRadius)
Draw an Arc
#include<graphics.h>
#include<stdio.h>
#include<conio.h>
void main( )
{
int gd = DETECT, gm;
initgraph(&gd, &gm, "C:TCBGI");
arc(100,100,90,280,10);
getch( );
closegraph( );
}
arc(x1,y1,StartingAngle,EndingAngle,Radius)
Draw a Bar
#include<graphics.h>
#include<stdio.h>
#include<conio.h>
void main( )
{
int gd = DETECT, gm;
initgraph(&gd, &gm, "C:TCBGI");
bar(100,100,200,200);
getch( );
closegraph( );
}
Bar(Left,Top,Right,Bottom)
Draw a 3D bar
#include<graphics.h>
#include<stdio.h>
#include<conio.h>
void main( )
{
int gd = DETECT, gm;
initgraph(&gd, &gm, "C:TCBGI");
bar3d(100,100,200,200,10,1);
getch( );
closegraph( );
}
Bar3d(left,top,right,bottom,depth,topflag)
Assignment
Q.1 Draw a flag using line and circle.
Q.2 Draw a hut using line, rectangle and circle.
Q.3 Draw a smiley face using ellipse, circle and arc.
Q.4 Draw a fish using arc, circle and line.

Mais conteúdo relacionado

Mais procurados

Hidden surfaces
Hidden surfacesHidden surfaces
Hidden surfaces
Mohd Arif
 
The sutherland hodgeman polygon clipping algorithm
The sutherland hodgeman polygon clipping algorithmThe sutherland hodgeman polygon clipping algorithm
The sutherland hodgeman polygon clipping algorithm
Mani Kanth
 
Lec 17 heap data structure
Lec 17 heap data structureLec 17 heap data structure
Lec 17 heap data structure
Sajid Marwat
 

Mais procurados (20)

Computer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and EllipseComputer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and Ellipse
 
Dynamic Programming
Dynamic ProgrammingDynamic Programming
Dynamic Programming
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
 
Hidden surfaces
Hidden surfacesHidden surfaces
Hidden surfaces
 
Threaded Binary Tree
Threaded Binary TreeThreaded Binary Tree
Threaded Binary Tree
 
Lec1
Lec1Lec1
Lec1
 
Job sequencing with Deadlines
Job sequencing with DeadlinesJob sequencing with Deadlines
Job sequencing with Deadlines
 
data science chapter-4,5,6
data science chapter-4,5,6data science chapter-4,5,6
data science chapter-4,5,6
 
Curve clipping
Curve clippingCurve clipping
Curve clipping
 
Analysis of algorithm
Analysis of algorithmAnalysis of algorithm
Analysis of algorithm
 
Backtracking
BacktrackingBacktracking
Backtracking
 
Tree - Data Structure
Tree - Data StructureTree - Data Structure
Tree - Data Structure
 
Computer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsComputer Graphics Lab File C Programs
Computer Graphics Lab File C Programs
 
Python Programming: Lists, Modules, Exceptions
Python Programming: Lists, Modules, ExceptionsPython Programming: Lists, Modules, Exceptions
Python Programming: Lists, Modules, Exceptions
 
The sutherland hodgeman polygon clipping algorithm
The sutherland hodgeman polygon clipping algorithmThe sutherland hodgeman polygon clipping algorithm
The sutherland hodgeman polygon clipping algorithm
 
Prims and kruskal algorithms
Prims and kruskal algorithmsPrims and kruskal algorithms
Prims and kruskal algorithms
 
Lec 17 heap data structure
Lec 17 heap data structureLec 17 heap data structure
Lec 17 heap data structure
 
sutherland- Hodgeman Polygon clipping
sutherland- Hodgeman Polygon clippingsutherland- Hodgeman Polygon clipping
sutherland- Hodgeman Polygon clipping
 
module5_backtrackingnbranchnbound_2022.pdf
module5_backtrackingnbranchnbound_2022.pdfmodule5_backtrackingnbranchnbound_2022.pdf
module5_backtrackingnbranchnbound_2022.pdf
 
Non Deterministic and Deterministic Problems
Non Deterministic and Deterministic Problems Non Deterministic and Deterministic Problems
Non Deterministic and Deterministic Problems
 

Destaque

Computer Graphics Practical
Computer Graphics PracticalComputer Graphics Practical
Computer Graphics Practical
Neha Sharma
 
Course plan computer graphics lab
Course plan computer graphics labCourse plan computer graphics lab
Course plan computer graphics lab
aa11bb11
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygons
Ketan Jani
 

Destaque (20)

Computer Graphics Practical
Computer Graphics PracticalComputer Graphics Practical
Computer Graphics Practical
 
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
 
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
 
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)
 
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++
 
Unit 11. Graphics
Unit 11. GraphicsUnit 11. Graphics
Unit 11. Graphics
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
 
Graphics in C programming
Graphics in C programmingGraphics in C programming
Graphics in C programming
 
Lab manual of C++
Lab manual of C++Lab manual of C++
Lab manual of C++
 
Java Script ppt
Java Script pptJava Script ppt
Java Script ppt
 
Course plan computer graphics lab
Course plan computer graphics labCourse plan computer graphics lab
Course plan computer graphics lab
 
Computer graphics
Computer graphics Computer graphics
Computer graphics
 
Gfx2014 Graphics Workshop - Lab manual
Gfx2014 Graphics Workshop - Lab manualGfx2014 Graphics Workshop - Lab manual
Gfx2014 Graphics Workshop - Lab manual
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygons
 
Graphics point clipping c program
Graphics point clipping c programGraphics point clipping c program
Graphics point clipping c program
 

Semelhante a Basics of Computer graphics lab

bfd23fd7-0d89-45c0-8b82-c991b30ed375.pdf
bfd23fd7-0d89-45c0-8b82-c991b30ed375.pdfbfd23fd7-0d89-45c0-8b82-c991b30ed375.pdf
bfd23fd7-0d89-45c0-8b82-c991b30ed375.pdf
shehabhamad_90
 
Output Primitives in Computer Graphics and Multimedia
Output Primitives in Computer Graphics and MultimediaOutput Primitives in Computer Graphics and Multimedia
Output Primitives in Computer Graphics and Multimedia
saranyan75
 
Computer Graphics and Multimedia Output primitives
Computer Graphics and Multimedia Output primitivesComputer Graphics and Multimedia Output primitives
Computer Graphics and Multimedia Output primitives
saranyan75
 
Open GL T0074 56 sm4
Open GL T0074 56 sm4Open GL T0074 56 sm4
Open GL T0074 56 sm4
Roziq Bahtiar
 

Semelhante a Basics of Computer graphics lab (20)

Computer graphics
Computer graphics   Computer graphics
Computer graphics
 
Computer graphics
Computer graphics   Computer graphics
Computer graphics
 
Computer graphics lab assignment
Computer graphics lab assignmentComputer graphics lab assignment
Computer graphics lab assignment
 
raster algorithm.pdf
raster algorithm.pdfraster algorithm.pdf
raster algorithm.pdf
 
bfd23fd7-0d89-45c0-8b82-c991b30ed375.pdf
bfd23fd7-0d89-45c0-8b82-c991b30ed375.pdfbfd23fd7-0d89-45c0-8b82-c991b30ed375.pdf
bfd23fd7-0d89-45c0-8b82-c991b30ed375.pdf
 
Computer Graphics in Java and Scala - Part 1b
Computer Graphics in Java and Scala - Part 1bComputer Graphics in Java and Scala - Part 1b
Computer Graphics in Java and Scala - Part 1b
 
Cg lab cse-v (1) (1)
Cg lab cse-v (1) (1)Cg lab cse-v (1) (1)
Cg lab cse-v (1) (1)
 
7. chapter vi
7. chapter vi7. chapter vi
7. chapter vi
 
Output Primitives in Computer Graphics and Multimedia
Output Primitives in Computer Graphics and MultimediaOutput Primitives in Computer Graphics and Multimedia
Output Primitives in Computer Graphics and Multimedia
 
Computer Graphics and Multimedia Output primitives
Computer Graphics and Multimedia Output primitivesComputer Graphics and Multimedia Output primitives
Computer Graphics and Multimedia Output primitives
 
Computer graphics programs in c++
Computer graphics programs in c++Computer graphics programs in c++
Computer graphics programs in c++
 
computer graphics practicals
computer graphics practicalscomputer graphics practicals
computer graphics practicals
 
2Bytesprog2 course_2014_c9_graph
2Bytesprog2 course_2014_c9_graph2Bytesprog2 course_2014_c9_graph
2Bytesprog2 course_2014_c9_graph
 
Circles graphic
Circles graphicCircles graphic
Circles graphic
 
Intro to Python (High School) Unit #3
Intro to Python (High School) Unit #3Intro to Python (High School) Unit #3
Intro to Python (High School) Unit #3
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
Computer Graphics Unit 1
Computer Graphics Unit 1Computer Graphics Unit 1
Computer Graphics Unit 1
 
Primitives
PrimitivesPrimitives
Primitives
 
Open GL T0074 56 sm4
Open GL T0074 56 sm4Open GL T0074 56 sm4
Open GL T0074 56 sm4
 
C Graphics Functions
C Graphics FunctionsC Graphics Functions
C Graphics Functions
 

Último

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Último (20)

ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 

Basics of Computer graphics lab

  • 2. How to run the graphics program in Turbo C++ • Open turbo C++ • Click on Option => Linker => Library • Click on Graphics(mark it as ‘X’) • Click on OK Now you can run your graphics programs.
  • 3. Basic functions to draw shapes in graphics Shape Function syntax pixel Draw a pixel Putpixel (X1,Y1,Color) Line Draw a line Line(X1,Y1,X2,Y2) Rectangle Draw a rectangle Rectangle(Left,Top,Right,Bottom) Circle Draw a circle Circle(X,Y,Radius) Ellipse Draw a ellipse Ellipse(X1,Y1,0,360,XaxisRadius,YaxisRadius) Arc Draw a arc Arc(X1,Y1,StartingAngle,EndingAngle,Radius) Bar Draw a filled rectangle Bar(Left,Top,Right,Bottom) Bar3d Draw a filled 3d rectangle Bar3d(Left,Top,Right,Bottom,depth,topflag) **topflag will be 0 or 1** Here X1=distance of first point of shape from X axis, X2=Distance of last point of shape from X axis Here Y1=distance of first point of shape from Y axis, Y2=Distance of last point of shape from Y axis
  • 4. Structure of graphics program #include<graphics.h> #include<stdio.h> #include<conio.h> void main( ) { int gd = DETECT, gm; initgraph(&gd, &gm, "C:TCBGI"); …………………… ……………………. getch( ); closegraph( ); } Location of BGI folder, where display files are saved. Write the location of (C:-TC-BGI) Initialization of graph
  • 5. Draw a Pixel #include<graphics.h> #include<stdio.h> #include<conio.h> void main( ) { int gd = DETECT, gm; initgraph(&gd, &gm, "C:TCBGI"); Putpixel(100,100,RED) getch( ); closegraph( ); } Putpixel(X1,Y1,Color)
  • 6. Draw a line #include<graphics.h> #include<stdio.h> #include<conio.h> void main( ) { int gd = DETECT, gm; initgraph(&gd, &gm, "C:TCBGI"); Line(100,100,200,200) getch( ); closegraph( ); } Line(X1,Y1,X2,Y2)
  • 7. Draw a Rectangle #include<graphics.h> #include<stdio.h> #include<conio.h> void main( ) { int gd = DETECT, gm; initgraph(&gd, &gm, "C:TCBGI"); Rectangle(100,100,200,200) getch( ); closegraph( ); } rectangle(X1,Y1,X2,Y2)
  • 8. Draw a circle #include<graphics.h> #include<stdio.h> #include<conio.h> void main( ) { int gd = DETECT, gm; initgraph(&gd, &gm, "C:TCBGI"); Circle(100,100,10) getch( ); closegraph( ); } circle(X1,Y1,radius)
  • 9. Draw an ellipse #include<graphics.h> #include<stdio.h> #include<conio.h> void main( ) { int gd = DETECT, gm; initgraph(&gd, &gm, "C:TCBGI"); ellipse(100,100,0,360,20,10); getch( ); closegraph( ); } ellipse(x1,y1,0,360,xAxisRadius,yAxisRadius)
  • 10. Draw an Arc #include<graphics.h> #include<stdio.h> #include<conio.h> void main( ) { int gd = DETECT, gm; initgraph(&gd, &gm, "C:TCBGI"); arc(100,100,90,280,10); getch( ); closegraph( ); } arc(x1,y1,StartingAngle,EndingAngle,Radius)
  • 11. Draw a Bar #include<graphics.h> #include<stdio.h> #include<conio.h> void main( ) { int gd = DETECT, gm; initgraph(&gd, &gm, "C:TCBGI"); bar(100,100,200,200); getch( ); closegraph( ); } Bar(Left,Top,Right,Bottom)
  • 12. Draw a 3D bar #include<graphics.h> #include<stdio.h> #include<conio.h> void main( ) { int gd = DETECT, gm; initgraph(&gd, &gm, "C:TCBGI"); bar3d(100,100,200,200,10,1); getch( ); closegraph( ); } Bar3d(left,top,right,bottom,depth,topflag)
  • 13. Assignment Q.1 Draw a flag using line and circle. Q.2 Draw a hut using line, rectangle and circle. Q.3 Draw a smiley face using ellipse, circle and arc. Q.4 Draw a fish using arc, circle and line.