SlideShare a Scribd company logo
1 of 8
Download to read offline
Computer Graphics Concepts
“The picture worth’s, thousand words” is very famous Chinese saying. Really, literate can read few
sequences of characters but all can read the picture. It is out of bondage of literacy. Almost of high level
language supports graphics and this facility of language is exploited in building of GUI (Graphical User
Interface).
The computer graphics is concern with generation, representation, manipulation and display of pictures
with the aid of computer. It may be divided into three broad area (a) generative graphics, (b) cognitive
graphics, and (c) Image processing. Any graphics package has to furnish above tasks.
C / C++ support graphics, sounds and all the features of high level languages. It works in two
modes: Text mode and Graphics mode. The text mode supports only text and color, but not
sophisticated graphics. In text mode, graphics are presented by ASCII characters and some special
characters. The Graphics mode supports colors and special statements for sophisticated graphics and
animation. The graphics are array of pixels or patterns of pixels.
Pixel
The picture element is called pixels. It is a unit of presentation. Each pixel occupies some bits in memory.
We have listened the term raster or bitmap image. These images are composed by two- dimensional
array of pixels. Each pixel has horizontal and vertical location in image.
The horizontal scan lines are formed on CRT (Cathode Ray Tube) when the drawing cuts the horizontal
scan lines, cutting point is termed as pixels.
COLOR
The concept of background and foreground color is necessary for presentation of graphics. The success
of graphics designer depends on suitable combination of background and foreground colors. The color
of canvas is called background and color of text and graphics is called foreground color. For example, the
color of blackboard is a background and the color of written text or drawing is a foreground color. The
color is supported by both the modes.
Color Code Comments
BLACK 0 Background/ Background
BLUE 1 Background/ Background
GREEN 2 Background/ Background
CYAN 3 Background/ Background
RED 4 Background/ Background
MAGENTA 5 Background/ Background
BROWN 6 Background/ Background
LIGHTGRAY 7 Background/ Background
DRARKGRAY 8 Foreground
LIGHTBLUE 9 Foreground
LIGHTGREEN 10 Foreground
LIGHTCYAN 11 Foreground
LIGHTRED 12 Foreground
LIGHTMAGENTA 13 Foreground
YELLOW 14 Foreground
WHITE 15 Foreground
(a) void textcolor(int color);
From 0 to 15 colors, numbers or constants are used to set text colors.
Example:
textcolor (RED);
textcolor(4);
The blinking effect is added by adding 128 in color code or adding BLINK with color constant.
Example:
textcolor(RED+BLINK);
textcolor(132);
The code 4 is for RED color and 128 for BLINK.
(b) void textbackground(int color);
From 0 to 7, numbers or constants are used for colors. It is used to set background color of text.
Example:
textbackground(BLUE);
textbackground(1);
(c) gotoxy(col, row): It is used to place cursor at specified column and row. It contains integer as column and row
data type. In graphics, y-axis goes from top to bottom, not from left to right like as mathematics.
Example:
int col=50;
int row=45;
gotoxy(col, row); // it places cursor at column number 50 of rows 45.
Cputs(“BUDDHA”);
gotoxy(col, row);
(d) delay(int time): The function is supported by header file dos.h. it is used to delay next display.
Example:
Gotoxy(29, 10);
Cputs(“Department of computer Science”);
Delay(1000);
Gotoxy(29, 11);
Cputs(“Kashmir University”);
Program:
#include<conio.h>
void main()
{
crscr();
textcolor(RED);
gotoxy(27, 10);
cputs(“Welcome ”);
gotoxy(25, 11);
cputs(“ Iqbal Institute Of Technology And Management”);
gotoxy(25, 12);
getch();
}
Text in Graphics Mode
(a) Specify Text Font, Orientation and size:
Settextstyle(int font, int direction, int size)
Font //name of font
Direction //Horizontal or Vertical
Size // Size of Character
Font in standard library:
Value Constants File Comment
0 DEFAULT_FONT Compiler automatic Bit-mapped, 8×8
1 TRIPLEX_FONT Trip.chr Times-roman styles
2 SMALL_FONT Litt.chr For small letters
3 SANS_SERIF_FONT Sans.chr Heavy sans-serif
4 GOTHIC_FONT Gothic.chr Gothic
5 SCRIPT_FONT Scri.chr Script
6 SIMPLEX_FONT Simp.chr Light sans-serif
7 TRIPLEX_SRC_FONT Tscp.chr Italic
8 COMPLEX_FONT Lcom.chr Heavy times Roman
9 EUROPEAN_FONT Euro.chr Square letter
10 BOLD_FONT Bold.chr Thick letters
Example:
Fontsize=6;
Settextstyle(GOTHIC_FONT, HORIZ_DIR, fontsize);
Outtext(“Computer Graphics”);
Settextstyle(TRIPLEX_FONT, VERT_DIR, fontsize);
Outtext(“University”);
(b) Set Text Justification (Position Relative to Cursor Pointer, CP)
Settextjustify(int horizontal, int vertical)
Horizontal //horizontal justification constants
Vertical //vertical justification constants
Example:
Settextjustify(RIGHT_TEXT, TOP_TEXT);
Outtext(“IQBAL INSTITUTE OF TECHNOLOGY AND MANAGEMENT”);
Horizontal Justification:
Value Constants Comment
0 LEFT_TEXT CP at left of text (default justification)
1 CENTER_TEXT CP in horizontal center of text
2 RIGHT_TEXT CP at right of text
Vertical Justification:
Value Constants Comment
0 BOTTOM_TEXT CP at bottom of text
1 CENTER_TEXT CP in vertical center of text
(c) Change Character Size and Properties:
Setusercharsize(int multx, divx, multy, int divvy);
Multx //multiples with character
Divx //divides with character
Multy //multiplies height of character
Divvy //divides with character
Example:
Multx=1; divx=2;
Multy=1; divvy=2;
Setusercharsize(int multx, divx, multy, int divvy);
Outtext(“Happy New Year”);
(d) moveto(): The library function moveto() sets the location of CP, using two int arguments to indicate the X and Y
co-ordinates.
Syntax:
moveto(int column, int row);
(e) outtext(): Graphics text is displayed with the outtext() library.
Example:
Outtext(“University express”);
(f) Specifies Color:
Syntax:
setcolor(int color);
Shape
The concept of geometric shapes are described below. The library function line(0, rectangle(), circle() etc
are equipped with compiler for drawing purpose.
(a) Concept of Geometrical Shape:
Sn. Shape Comments
1. Line Line(x1, y1, x2, y2);
The first two arguments to the function
specify the X and Y co-ordinates of the
line’s starting points and the last two
arguments specify the end points.
Lineto(x, y);
This function draw a line from the CP
to (xCo-ordinate, yCo-ordinate)
2. Rectangle Rectangle(int left, int top, int right, int
bottom);
3. Bar3d Bar3d(int left, int top, int right, int
bottom, int depth, int topflag);
4. Circle Circle(int x, int y, int radius);
5. Eclipse Eclipse(int x, int y, startA, endA, int
xR1, inty R2);
6. Pieslice Pieslice(int x, int y, startA, endA, int
Radius);
7. Arc Arc(int x, int y, startA, endA, int
Radius);
8. Polygon Drawpoly(int side, int array);
(b) Specify Line Width and Style:
Setlinestyle9int style, unsigned pattern, int thickness);
Style //solid, dotted, dashed, etc
Pattern //user defined pattern when style is 4
Thickness //normal or thick
Style
Value Comment
0 SOLID_LINE
1 DOTTED_LINE
2 CENTER_LINE
3 DASHED_LINE
4 USERBIT_LINE
Thickness
Value Comment
0 NORM_WIDTH
1 THICK_WIDTH
(c) Specify Filling pattern and color:
Setfillstyle(int pattern, int color);
Pattern //pattern constants
Color //color constants
Fill patterns: Following fill patterns are available to fill in closed space. The concept of patterns is essential for
graphics designers.
Pattern Code Result
EMPTY_FILL 0 Solid Background
SOLID_FILL 1 Solid Color
LINE_FILL 2 Horizontal lines
LTSLASH_FILL 3 //// thin lines
SLASH_FILL 4 ////thick line
BKSLASH_FILL 5  thick lines
LTBSLASH_FILL 6  thin lines
HATCH_FILL 7 Light hatch
XHATCH_FILL 8 Heavy cross-hatch
INTERLEAVE_FILL 9 Interleaved lines
WIDE_DOT_FILL 10 Wide-spaced dot
CLOSE_DOT_FILL 11 Closed-spaced dots
USER_FILL 12 User-defined patterns
(d) Fill any Boundary Area:
Floodfill(int x, int y, int border);
X //x co-ordinate for fill start
Y //y co-ordinate for fill start
Border //color of border (fill stops here)
Example:
Flood(x, y, RED);
What is the seed point?
Seed point: A point for fill began is called seed point. The fill spreads outward from the seed point until it encounters
a boundary that has the color specified in the border parameter.
Program:
#include<graphics.h>
#include<conio.h>
Void main()
{
Int driver, mode;
driver=DETECT;
initgraph(&driver, &mode, tcbgi);
setcolor(GREEN);
rectangle(50, 10, 300, 200);
floodfill(250, 150, green);
getch();
closegraph();
}
Program:
#include<graphics.h>
#include<conio.h>
void main()
{
int driver, mode;
driver=DETECT;
initgraph(&driver, &mode, tcbgi);
setcolor(RED);
setfillstyle(1, RED);
bar3d(250, 10, 400, 50, 10, 1);
floodfill(255, 10, RED);
moveto(290, 24);
setcolor(BLUE);
outtext(“UNIVERSITY”);
getch();
closegraph();
}
Program:
/* Circle Programming */
#include<graphics.h>
#include<conio.h>
void main()
{
int driver, mode;
driver=DETECT;
initgraph(&driver, &mode, tcbgi);
setcolor(RED);
setfillstyle(2, 4);
circle(250, 150, 100);
floodfill(250, 150, 4);
getch();
closegraph();
}
Program:
/ * Circle */
#include<graphics.h>
#include<conio.h>
#include<math.h>
#define R 50
void main()
{
int x;
int driver, mode;
driver=DETECT;
initgraph(&driver, &mode, tcbgi);
setcolor(RED);
for(x=50; x<=20; x=x+30)
circle(x, x+10, R);
getch();
closegraph();
}
Program:
/* Pieslice Programming */
#include<graphics.h>
#include<conio.h>
void main()
{
int driver, mode;
driver=DETECT;
initgraph(&driver, &mode, tcbgi);
setcolor(RED);
setfillstyle(5, RED);
pieslice(250, 100, 0, 270, 100);
floodfill(255, 10, RED);
getch();
closegraph();
}
Program:
/ * The following program generates ellipse */
#include<graphics.h>
#include<conio.h>
void main()
{
int driver, mode;
driver=DETECT;
initgraph(&driver, &mode, tcbgi);
setcolor(BLUE);
setfillstyle(7, BLUE);
ellipse(250, 100, 0, 360, 100, 50);
floodfill(250, 110, BLUE);
getch();
closegraph();
}

More Related Content

What's hot

Computer graphics practical(jainam)
Computer graphics practical(jainam)Computer graphics practical(jainam)
Computer graphics practical(jainam)JAINAM KAPADIYA
 
Turbo C Graphics and Mouse Programming
Turbo C Graphics and Mouse ProgrammingTurbo C Graphics and Mouse Programming
Turbo C Graphics and Mouse ProgrammingHuzaifa Butt
 
C graphics programs file
C graphics programs fileC graphics programs file
C graphics programs fileshubham kanojia
 
Computer graphics
Computer graphicsComputer graphics
Computer graphicsamitsarda3
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manualAnkit Kumar
 
Basics of Computer graphics lab
Basics of Computer graphics labBasics of Computer graphics lab
Basics of Computer graphics labPriya Goyal
 
Graphics practical lab manual
Graphics practical lab manualGraphics practical lab manual
Graphics practical lab manualVivek Kumar Sinha
 
COMPUTER GRAPHICS LAB MANUAL
COMPUTER GRAPHICS LAB MANUALCOMPUTER GRAPHICS LAB MANUAL
COMPUTER GRAPHICS LAB MANUALVivek Kumar Sinha
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manualUma mohan
 
Computer graphics file
Computer graphics fileComputer graphics file
Computer graphics fileaman1001
 
Matlab Feature Extraction Using Segmentation And Edge Detection
Matlab Feature Extraction Using Segmentation And Edge DetectionMatlab Feature Extraction Using Segmentation And Edge Detection
Matlab Feature Extraction Using Segmentation And Edge DetectionDataminingTools Inc
 
Computer graphics lab assignment
Computer graphics lab assignmentComputer graphics lab assignment
Computer graphics lab assignmentAbdullah Al Shiam
 
Computer Graphics Lab
Computer Graphics LabComputer Graphics Lab
Computer Graphics LabNeil Mathew
 
Computer graphics
Computer graphicsComputer graphics
Computer graphicssnelkoli
 
Circles graphic
Circles graphicCircles graphic
Circles graphicalldesign
 

What's hot (20)

Computer graphics practical(jainam)
Computer graphics practical(jainam)Computer graphics practical(jainam)
Computer graphics practical(jainam)
 
Turbo C Graphics and Mouse Programming
Turbo C Graphics and Mouse ProgrammingTurbo C Graphics and Mouse Programming
Turbo C Graphics and Mouse Programming
 
Cg lab cse-v (1) (1)
Cg lab cse-v (1) (1)Cg lab cse-v (1) (1)
Cg lab cse-v (1) (1)
 
C graphics programs file
C graphics programs fileC graphics programs file
C graphics programs file
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
Graphics in C++
Graphics in C++Graphics in C++
Graphics in C++
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
 
Graphics Programming in C
Graphics Programming in CGraphics Programming in C
Graphics Programming in C
 
Graphics file
Graphics fileGraphics file
Graphics file
 
Basics of Computer graphics lab
Basics of Computer graphics labBasics of Computer graphics lab
Basics of Computer graphics lab
 
Graphics practical lab manual
Graphics practical lab manualGraphics practical lab manual
Graphics practical lab manual
 
COMPUTER GRAPHICS LAB MANUAL
COMPUTER GRAPHICS LAB MANUALCOMPUTER GRAPHICS LAB MANUAL
COMPUTER GRAPHICS LAB MANUAL
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
 
Computer graphics file
Computer graphics fileComputer graphics file
Computer graphics file
 
Matlab Feature Extraction Using Segmentation And Edge Detection
Matlab Feature Extraction Using Segmentation And Edge DetectionMatlab Feature Extraction Using Segmentation And Edge Detection
Matlab Feature Extraction Using Segmentation And Edge Detection
 
Computer graphics lab assignment
Computer graphics lab assignmentComputer graphics lab assignment
Computer graphics lab assignment
 
Test
TestTest
Test
 
Computer Graphics Lab
Computer Graphics LabComputer Graphics Lab
Computer Graphics Lab
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
Circles graphic
Circles graphicCircles graphic
Circles graphic
 

Similar to Computer Graphics Concepts

14 class design (1)
14 class design (1)14 class design (1)
14 class design (1)Satyam Gupta
 
Learn Creative Coding: Begin Programming with the Processing Language
Learn Creative Coding: Begin Programming with the Processing LanguageLearn Creative Coding: Begin Programming with the Processing Language
Learn Creative Coding: Begin Programming with the Processing Languageshelfrog
 
Learn Creative Coding: Begin Programming with the Processing Language
Learn Creative Coding: Begin Programming with the Processing LanguageLearn Creative Coding: Begin Programming with the Processing Language
Learn Creative Coding: Begin Programming with the Processing LanguageW M Harris
 
13 Graph Classes
13 Graph Classes13 Graph Classes
13 Graph Classespoffdeluxe
 
Computer Project For Class XII Topic - The Snake Game
Computer Project For Class XII Topic - The Snake Game Computer Project For Class XII Topic - The Snake Game
Computer Project For Class XII Topic - The Snake Game Pritam Samanta
 
Unit-1 basics of computer graphics
Unit-1 basics of computer graphicsUnit-1 basics of computer graphics
Unit-1 basics of computer graphicsAmol Gaikwad
 
CS 354 Pixel Updating
CS 354 Pixel UpdatingCS 354 Pixel Updating
CS 354 Pixel UpdatingMark Kilgard
 
Visula C# Programming Lecture 2
Visula C# Programming Lecture 2Visula C# Programming Lecture 2
Visula C# Programming Lecture 2Abou Bakr Ashraf
 
Reduce course notes class xii
Reduce course notes class xiiReduce course notes class xii
Reduce course notes class xiiSyed Zaid Irshad
 
Client Side Programming with Applet
Client Side Programming with AppletClient Side Programming with Applet
Client Side Programming with Appletbackdoor
 
13 graph classes_2
13 graph classes_213 graph classes_2
13 graph classes_2rohikhan
 
C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)Saifur Rahman
 
CAD - ENGINEERING DRAWING - RGPV,BHOPAL
CAD - ENGINEERING DRAWING - RGPV,BHOPALCAD - ENGINEERING DRAWING - RGPV,BHOPAL
CAD - ENGINEERING DRAWING - RGPV,BHOPALAbhishek Kandare
 

Similar to Computer Graphics Concepts (20)

Chapter 1
Chapter 1Chapter 1
Chapter 1
 
14 class design (1)
14 class design (1)14 class design (1)
14 class design (1)
 
14 class design
14 class design14 class design
14 class design
 
Pixel shaders
Pixel shadersPixel shaders
Pixel shaders
 
Learn Creative Coding: Begin Programming with the Processing Language
Learn Creative Coding: Begin Programming with the Processing LanguageLearn Creative Coding: Begin Programming with the Processing Language
Learn Creative Coding: Begin Programming with the Processing Language
 
Learn Creative Coding: Begin Programming with the Processing Language
Learn Creative Coding: Begin Programming with the Processing LanguageLearn Creative Coding: Begin Programming with the Processing Language
Learn Creative Coding: Begin Programming with the Processing Language
 
13 Graph Classes
13 Graph Classes13 Graph Classes
13 Graph Classes
 
Pixel shaders
Pixel shadersPixel shaders
Pixel shaders
 
Intake 37 6
Intake 37 6Intake 37 6
Intake 37 6
 
Chap1
Chap1Chap1
Chap1
 
K10947 Vikas ct
K10947 Vikas ctK10947 Vikas ct
K10947 Vikas ct
 
Computer Project For Class XII Topic - The Snake Game
Computer Project For Class XII Topic - The Snake Game Computer Project For Class XII Topic - The Snake Game
Computer Project For Class XII Topic - The Snake Game
 
Unit-1 basics of computer graphics
Unit-1 basics of computer graphicsUnit-1 basics of computer graphics
Unit-1 basics of computer graphics
 
CS 354 Pixel Updating
CS 354 Pixel UpdatingCS 354 Pixel Updating
CS 354 Pixel Updating
 
Visula C# Programming Lecture 2
Visula C# Programming Lecture 2Visula C# Programming Lecture 2
Visula C# Programming Lecture 2
 
Reduce course notes class xii
Reduce course notes class xiiReduce course notes class xii
Reduce course notes class xii
 
Client Side Programming with Applet
Client Side Programming with AppletClient Side Programming with Applet
Client Side Programming with Applet
 
13 graph classes_2
13 graph classes_213 graph classes_2
13 graph classes_2
 
C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)
 
CAD - ENGINEERING DRAWING - RGPV,BHOPAL
CAD - ENGINEERING DRAWING - RGPV,BHOPALCAD - ENGINEERING DRAWING - RGPV,BHOPAL
CAD - ENGINEERING DRAWING - RGPV,BHOPAL
 

Recently uploaded

Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 

Recently uploaded (20)

Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 

Computer Graphics Concepts

  • 1. Computer Graphics Concepts “The picture worth’s, thousand words” is very famous Chinese saying. Really, literate can read few sequences of characters but all can read the picture. It is out of bondage of literacy. Almost of high level language supports graphics and this facility of language is exploited in building of GUI (Graphical User Interface). The computer graphics is concern with generation, representation, manipulation and display of pictures with the aid of computer. It may be divided into three broad area (a) generative graphics, (b) cognitive graphics, and (c) Image processing. Any graphics package has to furnish above tasks. C / C++ support graphics, sounds and all the features of high level languages. It works in two modes: Text mode and Graphics mode. The text mode supports only text and color, but not sophisticated graphics. In text mode, graphics are presented by ASCII characters and some special characters. The Graphics mode supports colors and special statements for sophisticated graphics and animation. The graphics are array of pixels or patterns of pixels. Pixel The picture element is called pixels. It is a unit of presentation. Each pixel occupies some bits in memory. We have listened the term raster or bitmap image. These images are composed by two- dimensional array of pixels. Each pixel has horizontal and vertical location in image. The horizontal scan lines are formed on CRT (Cathode Ray Tube) when the drawing cuts the horizontal scan lines, cutting point is termed as pixels. COLOR The concept of background and foreground color is necessary for presentation of graphics. The success of graphics designer depends on suitable combination of background and foreground colors. The color of canvas is called background and color of text and graphics is called foreground color. For example, the color of blackboard is a background and the color of written text or drawing is a foreground color. The color is supported by both the modes. Color Code Comments BLACK 0 Background/ Background BLUE 1 Background/ Background GREEN 2 Background/ Background CYAN 3 Background/ Background RED 4 Background/ Background MAGENTA 5 Background/ Background BROWN 6 Background/ Background LIGHTGRAY 7 Background/ Background
  • 2. DRARKGRAY 8 Foreground LIGHTBLUE 9 Foreground LIGHTGREEN 10 Foreground LIGHTCYAN 11 Foreground LIGHTRED 12 Foreground LIGHTMAGENTA 13 Foreground YELLOW 14 Foreground WHITE 15 Foreground (a) void textcolor(int color); From 0 to 15 colors, numbers or constants are used to set text colors. Example: textcolor (RED); textcolor(4); The blinking effect is added by adding 128 in color code or adding BLINK with color constant. Example: textcolor(RED+BLINK); textcolor(132); The code 4 is for RED color and 128 for BLINK. (b) void textbackground(int color); From 0 to 7, numbers or constants are used for colors. It is used to set background color of text. Example: textbackground(BLUE); textbackground(1); (c) gotoxy(col, row): It is used to place cursor at specified column and row. It contains integer as column and row data type. In graphics, y-axis goes from top to bottom, not from left to right like as mathematics. Example: int col=50; int row=45; gotoxy(col, row); // it places cursor at column number 50 of rows 45. Cputs(“BUDDHA”); gotoxy(col, row);
  • 3. (d) delay(int time): The function is supported by header file dos.h. it is used to delay next display. Example: Gotoxy(29, 10); Cputs(“Department of computer Science”); Delay(1000); Gotoxy(29, 11); Cputs(“Kashmir University”); Program: #include<conio.h> void main() { crscr(); textcolor(RED); gotoxy(27, 10); cputs(“Welcome ”); gotoxy(25, 11); cputs(“ Iqbal Institute Of Technology And Management”); gotoxy(25, 12); getch(); } Text in Graphics Mode (a) Specify Text Font, Orientation and size: Settextstyle(int font, int direction, int size) Font //name of font Direction //Horizontal or Vertical Size // Size of Character Font in standard library: Value Constants File Comment 0 DEFAULT_FONT Compiler automatic Bit-mapped, 8×8 1 TRIPLEX_FONT Trip.chr Times-roman styles 2 SMALL_FONT Litt.chr For small letters 3 SANS_SERIF_FONT Sans.chr Heavy sans-serif 4 GOTHIC_FONT Gothic.chr Gothic 5 SCRIPT_FONT Scri.chr Script 6 SIMPLEX_FONT Simp.chr Light sans-serif 7 TRIPLEX_SRC_FONT Tscp.chr Italic 8 COMPLEX_FONT Lcom.chr Heavy times Roman 9 EUROPEAN_FONT Euro.chr Square letter 10 BOLD_FONT Bold.chr Thick letters
  • 4. Example: Fontsize=6; Settextstyle(GOTHIC_FONT, HORIZ_DIR, fontsize); Outtext(“Computer Graphics”); Settextstyle(TRIPLEX_FONT, VERT_DIR, fontsize); Outtext(“University”); (b) Set Text Justification (Position Relative to Cursor Pointer, CP) Settextjustify(int horizontal, int vertical) Horizontal //horizontal justification constants Vertical //vertical justification constants Example: Settextjustify(RIGHT_TEXT, TOP_TEXT); Outtext(“IQBAL INSTITUTE OF TECHNOLOGY AND MANAGEMENT”); Horizontal Justification: Value Constants Comment 0 LEFT_TEXT CP at left of text (default justification) 1 CENTER_TEXT CP in horizontal center of text 2 RIGHT_TEXT CP at right of text Vertical Justification: Value Constants Comment 0 BOTTOM_TEXT CP at bottom of text 1 CENTER_TEXT CP in vertical center of text (c) Change Character Size and Properties: Setusercharsize(int multx, divx, multy, int divvy); Multx //multiples with character Divx //divides with character Multy //multiplies height of character Divvy //divides with character Example: Multx=1; divx=2; Multy=1; divvy=2; Setusercharsize(int multx, divx, multy, int divvy); Outtext(“Happy New Year”); (d) moveto(): The library function moveto() sets the location of CP, using two int arguments to indicate the X and Y co-ordinates. Syntax: moveto(int column, int row); (e) outtext(): Graphics text is displayed with the outtext() library. Example: Outtext(“University express”);
  • 5. (f) Specifies Color: Syntax: setcolor(int color); Shape The concept of geometric shapes are described below. The library function line(0, rectangle(), circle() etc are equipped with compiler for drawing purpose. (a) Concept of Geometrical Shape: Sn. Shape Comments 1. Line Line(x1, y1, x2, y2); The first two arguments to the function specify the X and Y co-ordinates of the line’s starting points and the last two arguments specify the end points. Lineto(x, y); This function draw a line from the CP to (xCo-ordinate, yCo-ordinate) 2. Rectangle Rectangle(int left, int top, int right, int bottom); 3. Bar3d Bar3d(int left, int top, int right, int bottom, int depth, int topflag); 4. Circle Circle(int x, int y, int radius); 5. Eclipse Eclipse(int x, int y, startA, endA, int xR1, inty R2); 6. Pieslice Pieslice(int x, int y, startA, endA, int Radius); 7. Arc Arc(int x, int y, startA, endA, int Radius); 8. Polygon Drawpoly(int side, int array); (b) Specify Line Width and Style: Setlinestyle9int style, unsigned pattern, int thickness); Style //solid, dotted, dashed, etc Pattern //user defined pattern when style is 4 Thickness //normal or thick Style Value Comment 0 SOLID_LINE 1 DOTTED_LINE 2 CENTER_LINE 3 DASHED_LINE 4 USERBIT_LINE Thickness Value Comment 0 NORM_WIDTH 1 THICK_WIDTH
  • 6. (c) Specify Filling pattern and color: Setfillstyle(int pattern, int color); Pattern //pattern constants Color //color constants Fill patterns: Following fill patterns are available to fill in closed space. The concept of patterns is essential for graphics designers. Pattern Code Result EMPTY_FILL 0 Solid Background SOLID_FILL 1 Solid Color LINE_FILL 2 Horizontal lines LTSLASH_FILL 3 //// thin lines SLASH_FILL 4 ////thick line BKSLASH_FILL 5 thick lines LTBSLASH_FILL 6 thin lines HATCH_FILL 7 Light hatch XHATCH_FILL 8 Heavy cross-hatch INTERLEAVE_FILL 9 Interleaved lines WIDE_DOT_FILL 10 Wide-spaced dot CLOSE_DOT_FILL 11 Closed-spaced dots USER_FILL 12 User-defined patterns (d) Fill any Boundary Area: Floodfill(int x, int y, int border); X //x co-ordinate for fill start Y //y co-ordinate for fill start Border //color of border (fill stops here) Example: Flood(x, y, RED); What is the seed point? Seed point: A point for fill began is called seed point. The fill spreads outward from the seed point until it encounters a boundary that has the color specified in the border parameter. Program: #include<graphics.h> #include<conio.h> Void main() { Int driver, mode; driver=DETECT; initgraph(&driver, &mode, tcbgi); setcolor(GREEN);
  • 7. rectangle(50, 10, 300, 200); floodfill(250, 150, green); getch(); closegraph(); } Program: #include<graphics.h> #include<conio.h> void main() { int driver, mode; driver=DETECT; initgraph(&driver, &mode, tcbgi); setcolor(RED); setfillstyle(1, RED); bar3d(250, 10, 400, 50, 10, 1); floodfill(255, 10, RED); moveto(290, 24); setcolor(BLUE); outtext(“UNIVERSITY”); getch(); closegraph(); } Program: /* Circle Programming */ #include<graphics.h> #include<conio.h> void main() { int driver, mode; driver=DETECT; initgraph(&driver, &mode, tcbgi); setcolor(RED); setfillstyle(2, 4); circle(250, 150, 100); floodfill(250, 150, 4); getch(); closegraph(); } Program: / * Circle */ #include<graphics.h> #include<conio.h> #include<math.h> #define R 50 void main() { int x; int driver, mode; driver=DETECT;
  • 8. initgraph(&driver, &mode, tcbgi); setcolor(RED); for(x=50; x<=20; x=x+30) circle(x, x+10, R); getch(); closegraph(); } Program: /* Pieslice Programming */ #include<graphics.h> #include<conio.h> void main() { int driver, mode; driver=DETECT; initgraph(&driver, &mode, tcbgi); setcolor(RED); setfillstyle(5, RED); pieslice(250, 100, 0, 270, 100); floodfill(255, 10, RED); getch(); closegraph(); } Program: / * The following program generates ellipse */ #include<graphics.h> #include<conio.h> void main() { int driver, mode; driver=DETECT; initgraph(&driver, &mode, tcbgi); setcolor(BLUE); setfillstyle(7, BLUE); ellipse(250, 100, 0, 360, 100, 50); floodfill(250, 110, BLUE); getch(); closegraph(); }