SlideShare a Scribd company logo
1 of 21
Group Name 
Pure ones 
Presenters 
Ali Murtaza 11014119-044 
M. Hamid 11014119-007 
QasimAli 11014119-128 
M. Tayyab Chema 11014119-045 
Ahsan Raza 11014119-017
 Turbo C has a good collection of graphics libraries. 
If you know the basics of C, you can easily learn 
graphics programming. 
Why we use graphics ? 
 We use graphics in C language to give a different 
look to our program. 
 Function related graphics are use to create different 
shapes in different colour.
Files for compiler to work in graphics. 
 The header file “graphics.h” i.e built-in function is 
use in graphics. 
 These files stores in Borland graphics interface (BGI) 
files. These files contain graphics drive program. 
Display modes in C . 
 The output of a program can be displayed on the 
screen in two modes. 
 Text mode. 
 Graphics mode.
 In text mode screen is normally divided into rows 
and columns. We can move the cursor to specified 
location by using “gotoxy (x,y);” function. 
 In text mode there are 80 columns (0-79) and 25 
rows (0-24). 
 In text mode only text can be displayed.
 In graphics mode the screen is divided into small 
dots called pixels. 
For example: 
In VGA monitor the screen is divided into 480 
rows and 640 columns of dots. Thus the monitor 
VGA screen is divided into 640 X 480 pixels. 
 The resolution of different type of (display adopter) 
are 
 VGA 640 X 480 
 SVGA 800 X 600
 The computer display system must be initialized into 
graphics mode before calling the graphics function. 
 Function for initialization of graphics: 
The “initgraph” function is used to initialized the 
graphics mode. 
 This function is already defined in “graphics.h” 
header file.
 Syntax 
The syntax of initgraph is: 
initgraph(&driver, &mode,”path”); 
 Driver 
Represents the graphics driver installed in computer. It 
may be an integer variable or an integer constant. 
 Mode 
Represents the output resolution on the computer screen. 
The normal mode for VGA is VGAHI. It gives the highest 
resolution.
 & 
Represents the addresses of constants for driver and 
mode. 
 Path 
Represents the path of VGA driver. 
Which “ C:compiler nameBGI”.
There are two method of using initgraph function. 
 Manually 
In this way you have to tell the computer all about drivers or 
modes of VGA. In this way you don’t have to use & operator. 
For example: initgraph(vga,vgahi,”C:compiler nameBGI ”). 
 Auto-detect 
In this method you have only declare two integer type variables 
name as you wish. Initialize the 1st variable with a key word 
“DETECT”. In this method we should use & operator. 
For example: initgraph(&driver, &mode,”C:compiler nameBGI”);
 The cleardevice function is used to clear screen in 
graphics mode as clrscr( ) function is used in text 
mode. 
 Syntax cleardevice( ); 
Closegraph function 
 The closegraph function is used to restore ( turn of all the 
graphics ) the screen into text mode. 
 Syntax closegraph();
 The outtext function is used to print text on the screen 
in graphics mode. 
 Syntax outtext(Any sentence or character); 
Moveto function 
 The moveto function is used to move the cursor on the screen 
in specific location. 
 Syntax moveto(x , y); 
X represents the x-coordinate of the screen. 
Y represents the y-coordinate of the screen.
#include<conio.h> 
#include<graphics.h> 
void main() 
{ 
cleardevice(); 
int d,m; 
d= DETECT; 
initgraph( &d, &g, “C:TCBGI”); 
outtext(I love programming); 
moveto (250,179); 
outtext(I love programming); 
getch(); 
closegraph(); 
}
 The outtextxy function is similar to the outtext function but it is 
used to print text on the specified location. This function is both to 
outtext and moveto function. 
 Syntax outtextxy(x,y,”any string or character”); 
Settextstyle function 
 The settextstyle function is used to define text style in graphics 
mode. 
 Syntax settextstyle(style, direction, size); 
 Style represents the font style and its value is 0-10. 
 Direction represents the direction of text (horizontal or vertical) its 
value is 0-1. 
 Size represents the font size of the text its value is 0-72.
 The setcolor function is used to define the color of the 
object or text in graphics mode. 
 Syntax setcolor(color ); 
 There are 16 color in declared in graphics.h . 
BLACK: 0 BLUE: 1 GREEN: 2 
CYAN: 3 RED: 4 MAGENTA: 5 
BROWN: 6 LIGHTGRAY: 7 DARKGRAY: 8 
LIGHTBLUE: 9 LIGHTGREEN: 10 LIGHTCYAN: 11 
LIGHTRED: 12 LIGHTMAGENTA: 13 
YELLOW: 14 WHITE: 15
 The setbkcolor function is used to define back ground 
color on the output screen. 
 Syntax setbkcolor(color);
#include<conio.h> 
#include<graphics.h> 
void main() 
{ 
cleardevice(); 
int d=DETECT, m; 
initgraph(&d, &m, “C:TCBGI”); 
setbkcolor(5); 
setcolor(1); 
settextstyle(1,0,5); 
outtextxy(75,8,”Pakistan”); 
setcolor(15); 
settextstyle(1,1,5); 
outtextxy(75,40,”Pakistan”); 
getch(); 
closegraph(); 
}
 The circle function is used to display the circle on the 
out put screen. 
 Syntax circle( x, y, radius ); 
Arc function 
 The arc function is used to draw a circular arc starting from a 
specified angle from to another specified angle. 
 Syntax arc ( x, y, starting angle, ending angle, radius); 
 Where all parameters are both circle and arc have integer type.
 The line function is used to draw a line between two points on 
the screen. 
 Syntax line (x1,y1,x2,y2); 
Rectangle function 
 The rectangle function is used to draw a rectangle between 
two points on the screen. 
 Syntax rectangle (x1,y1,x2,y2); 
 Where x1, y1 specify the x ,y coordinate of the first point. And 
x2 , y2 specify the x , y coordinate of the second point. All 
four parameters are integer type.
#include<conio.h> 
#include<graphics.h> 
void main() 
{ int d=DETECT, m; 
cleardevice(); 
initgraph( &d, &m, “C:TCBGI”); 
outtextxy(35,65,”Circle”); 
circle(50,40,15); 
outtextxy(150,60,”Arc”); 
arc(155,40,0,180,15); 
outtextxy(42,160,”Rectangle”); 
rectangle(135,100,120,150); 
outtextxy(185,120,”Line”); 
line(140,100,230,100); 
getch(); 
closegraph(); 
}
Graphics in C++

More Related Content

What's hot (20)

Introduction to Input/Output Functions in C
Introduction to Input/Output Functions in CIntroduction to Input/Output Functions in C
Introduction to Input/Output Functions in C
 
Raster scan system
Raster scan systemRaster scan system
Raster scan system
 
Array and functions
Array and functionsArray and functions
Array and functions
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading
 
Attributes of output Primitive
Attributes of output Primitive Attributes of output Primitive
Attributes of output Primitive
 
Graphics software
Graphics softwareGraphics software
Graphics software
 
Built in function
Built in functionBuilt in function
Built in function
 
Unit 3. Input and Output
Unit 3. Input and OutputUnit 3. Input and Output
Unit 3. Input and Output
 
Preprocessor directives in c language
Preprocessor directives in c languagePreprocessor directives in c language
Preprocessor directives in c language
 
Computer Graphics - clipping
Computer Graphics - clippingComputer Graphics - clipping
Computer Graphics - clipping
 
Applets in java
Applets in javaApplets in java
Applets in java
 
Dda line algorithm presentatiion
Dda line algorithm presentatiionDda line algorithm presentatiion
Dda line algorithm presentatiion
 
Video display devices
Video display devicesVideo display devices
Video display devices
 
Dynamic Memory Allocation(DMA)
Dynamic Memory Allocation(DMA)Dynamic Memory Allocation(DMA)
Dynamic Memory Allocation(DMA)
 
File Pointers
File PointersFile Pointers
File Pointers
 
Addressing sequencing
Addressing sequencingAddressing sequencing
Addressing sequencing
 
Register transfer language
Register transfer languageRegister transfer language
Register transfer language
 
graphics programming in java
graphics programming in javagraphics programming in java
graphics programming in java
 
Character generation techniques
Character generation techniquesCharacter generation techniques
Character generation techniques
 
Modes of data transfer
Modes of data transferModes of data transfer
Modes of data transfer
 

Viewers also liked

Computer Graphics Practical
Computer Graphics PracticalComputer Graphics Practical
Computer Graphics PracticalNeha Sharma
 
Lecture on graphics
Lecture on graphicsLecture on graphics
Lecture on graphicsRafi_Dar
 
Computer Graphics Applications
Computer Graphics ApplicationsComputer Graphics Applications
Computer Graphics ApplicationsSaravana Priya
 
برمجة الرسوم بلغة السي بلس بلس المرحلة الثالثة
     برمجة الرسوم بلغة السي بلس بلس المرحلة الثالثة     برمجة الرسوم بلغة السي بلس بلس المرحلة الثالثة
برمجة الرسوم بلغة السي بلس بلس المرحلة الثالثةميثاق المعموري
 
Basics of Computer graphics lab
Basics of Computer graphics labBasics of Computer graphics lab
Basics of Computer graphics labPriya Goyal
 
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
 
Introduction to computer graphics
Introduction to computer graphicsIntroduction to computer graphics
Introduction to computer graphicsKamal Acharya
 
computer graphics
computer graphicscomputer graphics
computer graphicsashpri156
 
Introduction to Computer graphics
Introduction to Computer graphics Introduction to Computer graphics
Introduction to Computer graphics PrathimaBaliga
 
applications of computer graphics
applications of computer graphicsapplications of computer graphics
applications of computer graphicsAaina Katyal
 
Computer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsComputer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsKandarp Tiwari
 
Computer Graphics Project- The Running Train
Computer Graphics Project- The Running TrainComputer Graphics Project- The Running Train
Computer Graphics Project- The Running TrainAmit Kumar
 
file handling c++
file handling c++file handling c++
file handling c++Guddu Spy
 

Viewers also liked (20)

Graphics Programming in C
Graphics Programming in CGraphics Programming in C
Graphics Programming in C
 
Computer Graphics Practical
Computer Graphics PracticalComputer Graphics Practical
Computer Graphics Practical
 
Lecture on graphics
Lecture on graphicsLecture on graphics
Lecture on graphics
 
Computer Graphics
Computer GraphicsComputer Graphics
Computer Graphics
 
Computer Graphics Applications
Computer Graphics ApplicationsComputer Graphics Applications
Computer Graphics Applications
 
lecture1 introduction to computer graphics(Computer graphics tutorials)
lecture1 introduction to computer graphics(Computer graphics tutorials)lecture1 introduction to computer graphics(Computer graphics tutorials)
lecture1 introduction to computer graphics(Computer graphics tutorials)
 
برمجة الرسوم بلغة السي بلس بلس المرحلة الثالثة
     برمجة الرسوم بلغة السي بلس بلس المرحلة الثالثة     برمجة الرسوم بلغة السي بلس بلس المرحلة الثالثة
برمجة الرسوم بلغة السي بلس بلس المرحلة الثالثة
 
Basics of Computer graphics lab
Basics of Computer graphics labBasics of Computer graphics lab
Basics of Computer graphics lab
 
Applications of computer graphics
Applications of computer graphicsApplications of computer graphics
Applications of computer 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)
 
Introduction to computer graphics
Introduction to computer graphicsIntroduction to computer graphics
Introduction to computer graphics
 
computer graphics
computer graphicscomputer graphics
computer graphics
 
Introduction to Computer graphics
Introduction to Computer graphics Introduction to Computer graphics
Introduction to Computer graphics
 
applications of computer graphics
applications of computer graphicsapplications of computer graphics
applications of computer graphics
 
c++ كتاب برمجه
  c++ كتاب برمجه  c++ كتاب برمجه
c++ كتاب برمجه
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
 
Lab safety good ppt
Lab safety   good pptLab safety   good ppt
Lab safety good ppt
 
Computer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsComputer Graphics Lab File C Programs
Computer Graphics Lab File C Programs
 
Computer Graphics Project- The Running Train
Computer Graphics Project- The Running TrainComputer Graphics Project- The Running Train
Computer Graphics Project- The Running Train
 
file handling c++
file handling c++file handling c++
file handling c++
 

Similar to Graphics in C++

Circles graphic
Circles graphicCircles graphic
Circles graphicalldesign
 
Computer graphics
Computer graphicsComputer graphics
Computer graphicsamitsarda3
 
Computer graphics practical(jainam)
Computer graphics practical(jainam)Computer graphics practical(jainam)
Computer graphics practical(jainam)JAINAM KAPADIYA
 
bfd23fd7-0d89-45c0-8b82-c991b30ed375.pdf
bfd23fd7-0d89-45c0-8b82-c991b30ed375.pdfbfd23fd7-0d89-45c0-8b82-c991b30ed375.pdf
bfd23fd7-0d89-45c0-8b82-c991b30ed375.pdfshehabhamad_90
 
Computer graphics
Computer graphics Computer graphics
Computer graphics shafiq sangi
 
Graphics programming in Java
Graphics programming in JavaGraphics programming in Java
Graphics programming in JavaTushar B Kute
 
Client Side Programming with Applet
Client Side Programming with AppletClient Side Programming with Applet
Client Side Programming with Appletbackdoor
 
Graphic Design Lab File.docx
Graphic Design Lab File.docxGraphic Design Lab File.docx
Graphic Design Lab File.docxPayalJindal19
 
CS 354 Viewing Stuff
CS 354 Viewing StuffCS 354 Viewing Stuff
CS 354 Viewing StuffMark Kilgard
 
Skia & Freetype - Android 2D Graphics Essentials
Skia & Freetype - Android 2D Graphics EssentialsSkia & Freetype - Android 2D Graphics Essentials
Skia & Freetype - Android 2D Graphics EssentialsKyungmin Lee
 
Google's HTML5 Work: what's next?
Google's HTML5 Work: what's next?Google's HTML5 Work: what's next?
Google's HTML5 Work: what's next?Patrick Chanezon
 
COMPUTER GRAPHICS PROJECT REPORT
COMPUTER GRAPHICS PROJECT REPORTCOMPUTER GRAPHICS PROJECT REPORT
COMPUTER GRAPHICS PROJECT REPORTvineet raj
 
Implementing a Simple Game using libGDX
Implementing a Simple Game using libGDXImplementing a Simple Game using libGDX
Implementing a Simple Game using libGDXJussi Pohjolainen
 
openGL basics for sample program (1).ppt
openGL basics for sample program (1).pptopenGL basics for sample program (1).ppt
openGL basics for sample program (1).pptHIMANKMISHRA2
 
openGL basics for sample program.ppt
openGL basics for sample program.pptopenGL basics for sample program.ppt
openGL basics for sample program.pptHIMANKMISHRA2
 

Similar to Graphics in C++ (20)

Circles graphic
Circles graphicCircles graphic
Circles graphic
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
Computer graphics practical(jainam)
Computer graphics practical(jainam)Computer graphics practical(jainam)
Computer graphics practical(jainam)
 
Applet life cycle
Applet life cycleApplet life cycle
Applet life cycle
 
Graphics mod
Graphics modGraphics mod
Graphics mod
 
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
Computer graphics Computer graphics
Computer graphics
 
UNIT-II CP DOC.docx
UNIT-II CP DOC.docxUNIT-II CP DOC.docx
UNIT-II CP DOC.docx
 
Graphics programming in Java
Graphics programming in JavaGraphics programming in Java
Graphics programming in Java
 
Client Side Programming with Applet
Client Side Programming with AppletClient Side Programming with Applet
Client Side Programming with Applet
 
Graphic Design Lab File.docx
Graphic Design Lab File.docxGraphic Design Lab File.docx
Graphic Design Lab File.docx
 
Bai 1
Bai 1Bai 1
Bai 1
 
CS 354 Viewing Stuff
CS 354 Viewing StuffCS 354 Viewing Stuff
CS 354 Viewing Stuff
 
Skia & Freetype - Android 2D Graphics Essentials
Skia & Freetype - Android 2D Graphics EssentialsSkia & Freetype - Android 2D Graphics Essentials
Skia & Freetype - Android 2D Graphics Essentials
 
Google's HTML5 Work: what's next?
Google's HTML5 Work: what's next?Google's HTML5 Work: what's next?
Google's HTML5 Work: what's next?
 
COMPUTER GRAPHICS PROJECT REPORT
COMPUTER GRAPHICS PROJECT REPORTCOMPUTER GRAPHICS PROJECT REPORT
COMPUTER GRAPHICS PROJECT REPORT
 
Implementing a Simple Game using libGDX
Implementing a Simple Game using libGDXImplementing a Simple Game using libGDX
Implementing a Simple Game using libGDX
 
openGL basics for sample program (1).ppt
openGL basics for sample program (1).pptopenGL basics for sample program (1).ppt
openGL basics for sample program (1).ppt
 
openGL basics for sample program.ppt
openGL basics for sample program.pptopenGL basics for sample program.ppt
openGL basics for sample program.ppt
 
Lab Activity 3
Lab Activity 3Lab Activity 3
Lab Activity 3
 

Recently uploaded

mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...RKavithamani
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 

Recently uploaded (20)

mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 

Graphics in C++

  • 1.
  • 2. Group Name Pure ones Presenters Ali Murtaza 11014119-044 M. Hamid 11014119-007 QasimAli 11014119-128 M. Tayyab Chema 11014119-045 Ahsan Raza 11014119-017
  • 3.  Turbo C has a good collection of graphics libraries. If you know the basics of C, you can easily learn graphics programming. Why we use graphics ?  We use graphics in C language to give a different look to our program.  Function related graphics are use to create different shapes in different colour.
  • 4. Files for compiler to work in graphics.  The header file “graphics.h” i.e built-in function is use in graphics.  These files stores in Borland graphics interface (BGI) files. These files contain graphics drive program. Display modes in C .  The output of a program can be displayed on the screen in two modes.  Text mode.  Graphics mode.
  • 5.  In text mode screen is normally divided into rows and columns. We can move the cursor to specified location by using “gotoxy (x,y);” function.  In text mode there are 80 columns (0-79) and 25 rows (0-24).  In text mode only text can be displayed.
  • 6.  In graphics mode the screen is divided into small dots called pixels. For example: In VGA monitor the screen is divided into 480 rows and 640 columns of dots. Thus the monitor VGA screen is divided into 640 X 480 pixels.  The resolution of different type of (display adopter) are  VGA 640 X 480  SVGA 800 X 600
  • 7.  The computer display system must be initialized into graphics mode before calling the graphics function.  Function for initialization of graphics: The “initgraph” function is used to initialized the graphics mode.  This function is already defined in “graphics.h” header file.
  • 8.  Syntax The syntax of initgraph is: initgraph(&driver, &mode,”path”);  Driver Represents the graphics driver installed in computer. It may be an integer variable or an integer constant.  Mode Represents the output resolution on the computer screen. The normal mode for VGA is VGAHI. It gives the highest resolution.
  • 9.  & Represents the addresses of constants for driver and mode.  Path Represents the path of VGA driver. Which “ C:compiler nameBGI”.
  • 10. There are two method of using initgraph function.  Manually In this way you have to tell the computer all about drivers or modes of VGA. In this way you don’t have to use & operator. For example: initgraph(vga,vgahi,”C:compiler nameBGI ”).  Auto-detect In this method you have only declare two integer type variables name as you wish. Initialize the 1st variable with a key word “DETECT”. In this method we should use & operator. For example: initgraph(&driver, &mode,”C:compiler nameBGI”);
  • 11.  The cleardevice function is used to clear screen in graphics mode as clrscr( ) function is used in text mode.  Syntax cleardevice( ); Closegraph function  The closegraph function is used to restore ( turn of all the graphics ) the screen into text mode.  Syntax closegraph();
  • 12.  The outtext function is used to print text on the screen in graphics mode.  Syntax outtext(Any sentence or character); Moveto function  The moveto function is used to move the cursor on the screen in specific location.  Syntax moveto(x , y); X represents the x-coordinate of the screen. Y represents the y-coordinate of the screen.
  • 13. #include<conio.h> #include<graphics.h> void main() { cleardevice(); int d,m; d= DETECT; initgraph( &d, &g, “C:TCBGI”); outtext(I love programming); moveto (250,179); outtext(I love programming); getch(); closegraph(); }
  • 14.  The outtextxy function is similar to the outtext function but it is used to print text on the specified location. This function is both to outtext and moveto function.  Syntax outtextxy(x,y,”any string or character”); Settextstyle function  The settextstyle function is used to define text style in graphics mode.  Syntax settextstyle(style, direction, size);  Style represents the font style and its value is 0-10.  Direction represents the direction of text (horizontal or vertical) its value is 0-1.  Size represents the font size of the text its value is 0-72.
  • 15.  The setcolor function is used to define the color of the object or text in graphics mode.  Syntax setcolor(color );  There are 16 color in declared in graphics.h . BLACK: 0 BLUE: 1 GREEN: 2 CYAN: 3 RED: 4 MAGENTA: 5 BROWN: 6 LIGHTGRAY: 7 DARKGRAY: 8 LIGHTBLUE: 9 LIGHTGREEN: 10 LIGHTCYAN: 11 LIGHTRED: 12 LIGHTMAGENTA: 13 YELLOW: 14 WHITE: 15
  • 16.  The setbkcolor function is used to define back ground color on the output screen.  Syntax setbkcolor(color);
  • 17. #include<conio.h> #include<graphics.h> void main() { cleardevice(); int d=DETECT, m; initgraph(&d, &m, “C:TCBGI”); setbkcolor(5); setcolor(1); settextstyle(1,0,5); outtextxy(75,8,”Pakistan”); setcolor(15); settextstyle(1,1,5); outtextxy(75,40,”Pakistan”); getch(); closegraph(); }
  • 18.  The circle function is used to display the circle on the out put screen.  Syntax circle( x, y, radius ); Arc function  The arc function is used to draw a circular arc starting from a specified angle from to another specified angle.  Syntax arc ( x, y, starting angle, ending angle, radius);  Where all parameters are both circle and arc have integer type.
  • 19.  The line function is used to draw a line between two points on the screen.  Syntax line (x1,y1,x2,y2); Rectangle function  The rectangle function is used to draw a rectangle between two points on the screen.  Syntax rectangle (x1,y1,x2,y2);  Where x1, y1 specify the x ,y coordinate of the first point. And x2 , y2 specify the x , y coordinate of the second point. All four parameters are integer type.
  • 20. #include<conio.h> #include<graphics.h> void main() { int d=DETECT, m; cleardevice(); initgraph( &d, &m, “C:TCBGI”); outtextxy(35,65,”Circle”); circle(50,40,15); outtextxy(150,60,”Arc”); arc(155,40,0,180,15); outtextxy(42,160,”Rectangle”); rectangle(135,100,120,150); outtextxy(185,120,”Line”); line(140,100,230,100); getch(); closegraph(); }