Borland Style Graphics for Dev C++)

Slides:



Advertisements
Similar presentations
2D Graphics Drawing Things. Graphics In your GUI, you might want to draw graphics E.g. draw lines, circles, shapes, draw strings etc The Graphics class.
Advertisements

 putpixel function plots a pixel at location (x, y) of specified color.  Declaration :- void putpixel(int x, int y, int color);
BGI graphics library And Visual Studio.
Graphics in MS-DOS Environment LEE HUN HEE. 1.Real Coordinate and Windows Coordinate ● Real Coordinate ->(x,y) ● Windows Coordinate ->(wx,wy) ∴ (x,y)->(wx,wy)
Laboratory Study II October, Java Programming Assignment  Write a program to calculate and output the distance traveled by a car on a tank of.
Graphics You draw on a Graphics object The Graphics object cannot directly be created by your code, instead one is generated when the method paintComponent.
Cosc 5/4730 Blackberry Drawing. Screen size With Blackberry devices, they have a known screen size in pixels. If you are programming for specific device.
PHY-102 SAPIntroductory GraphicsSlide 1 Introductory Graphics In this section we will learn how about how to draw graphics on the screen in Java:  Drawing.
Chapter 9 Color, Sound and Graphics
COMPUTER PROGRAMMING I Objective 8.03 Apply Animation and Graphic Methods in a Windows Form (4%)
Cascading Style Sheets. CSS stands for Cascading Style Sheets and is a simple styling language which allows attaching style to HTML elements. CSS is a.
Important Irvine Library Procedures Randomize Randomize –Initializes the seed of the random-number formula by both the Random32 and the RandomRange procedures.
Four simple expressions in meta. Data objects Pieces of data in a computer are called objects Today, we’ll talk about four kinds of objects Numbers Pictures.
C++ Graphics Primitives April 15th. void clearscreen(int c) –clear the screen to background color c –If c = 1 screen black.
Four simple expressions in meta. Data objects Pieces of data in a computer are called objects Today, we’ll talk about four kinds of objects Numbers Pictures.
1 Getting Started: C-Revisions and Introduction to Graphics Next: Simulation Essentials, Memory Handling.
Graphics. Graphics Features in Java Topics to be covered Topics to be covered Graphics Basics Graphics Basics Coordinate System Coordinate System Graphics,
XP Tutorial 7 New Perspectives on Microsoft Windows XP 1 Microsoft Windows XP Working with Graphics Tutorial 7.
COMPUTER GRAPHICS Prepared by S.MAHALAKSHMI Asst. Prof(Sr) / SCSE VIT University.
CGMB214: Introduction to Computer Graphics
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 26 – CheckWriter Application Introducing Graphics.
Session: 17. © Aptech Ltd. 2Canvas and JavaScript / Session 17  Describe Canvas in HTML5  Explain the procedure to draw lines  Explain the procedure.
Chapter 28 - Java Graphics and Java2D Outline 28.1Introduction 28.2Graphics Contexts and Graphics Objects 28.3Color Control 28.4Font Control 28.5Drawing.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 5 Working with Images Starting Out with Games & Graphics in.
Graphics in C language Lecture by Jameel Asghar IT Manager Department of CS&IT NED University of Engineering and Technology, Karachi.
GRAPHICS AND MOUSE PROGRAMMING IN C. Turbo C has a good collection of graphics libraries. If you know the basics of C, you can easily learn graphics programming.
Element. The element Used to dynamically draw graphics using javascript. Capable of drawing paths, circles, rectangles, text, and images.
Image Representation. Objectives  Bitmaps: resolution, colour depth and simple bitmap file calculations.  Vector graphics: drawing list – objects and.
Lecture 15: Intro to Graphics Yoni Fridman 7/25/01 7/25/01.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 2 Graphics Programming with C++ and the Dark GDK Library Starting.
Chapter 7 Graphics. © Daly and Wrigley Objectives Use Graphic Components: ▫ Strings ▫ Lines ▫ Rectangles ▫ Ovals ▫ Arcs Change the color and font of elements.
Excel – Lesson 2 Excel Lesson 2 Changing the Appearance of a Worksheet Microsoft Office 2007: Introductory Pasewark & Pasewark 1.
Programming for Artists ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 10 Fall 2010.
Lesson 10 Using AutoShapes, WordArt, and Comments Lesson 10 Using AutoShapes, WordArt, and Comments.
Graphic Basics in C ATS 315. The Graphics Window Will look something like this.
Computer Graphics Prepared By: Bahram Taheri Sept Amirkabir University of Technology & Birmingham University.
Loops & Graphics IP 10 Mr. Mellesmoen Recall Earlier we wrote a program listing numbers from 1 – 24 i=1 start: TextWindow.WriteLine(i) i=i+1 If.
Tkinter Canvas.
(C) 2010 Pearson Education, Inc. All rights reserved.  Class Graphics (from package java.awt) provides various methods for drawing text and shapes onto.
Visual Basic Programming Introduction VB is one of the High level language VB has evolved from the BASIC language. BASIC stands for Beginners All-purpose.
Introduction to Drafting and Design In order to begin our drawing we have to set the drawing limits or the paper size.
Images Part 11 dbg. 2 Images The form and several controls can display a number of different types of image files in the BackgroundImage Property. These.
Paint Tutorial Created February 2006 Start Paint: Start>Programs>Accessories>Paint.
Now… The Basics of Design Basic Elements of Design Dots Lines Shapes Color Type Size Direction.
CSC1401 Drawing in Java - 1. Goals Understand at a conceptual and practical level How to use the Turtle class to draw on a picture How to use the java.awt.Graphics.
ATTRIBUTE OF OUTPUT PRIMITIVES. Attribute of Output Primitives 30/9/2008 A.Aruna/Assistant professor/IT/SNSCE 2 Definition Line Attribute Curve Attribute.
Graphics Basic Concepts 1.  A graphic is an image or visual representation of an object.  A visual representation such as a photo, illustration or diagram.
12 Graphics and Java 2D™.
Chapter 8 Graphics.
Graphical Output Graphical Text.
Computer Programming I
Lesson One: The Beginning Chapter 1: Pixels Learning Processing Daniel Shiffman Presentation by Donald W. Smith Graphics from
Chapter 5 Working with Images
Images Presentation Name Course Name Unit # – Lesson #.# – Lesson Name
BASIC DRAWING COMMANDS FOR AUTOCAD
Chapter 10 Graphics.
First text statement positioned here at guide intersection
Basic Graphics Drawing Shapes 1.
Lecture No 9 Graphics.
Chapter 2 Graphics Programming with C++ and the Dark GDK Library
Otasuke GP-EX! Chapter 1 Menu Screen.
Graphics Animation Using Terrapin LOGO
Images Presentation Name Course Name Unit # – Lesson #.# – Lesson Name
Otasuke GP-EX! Chapter 2 Run State Screen.
Topics Graphical User Interfaces Using the tkinter Module
Chapter 8 Graphics.
Using Logo and Logic This presentation uses a version of Logo called StarLogo available through MIT. It can be downloaded for free and installed on your.
Chapter 14 Drawing in a Window
More on operators and procedures in the Linked
JavaScript – Let’s Draw!
Presentation transcript:

Borland Style Graphics for Dev C++) Turbo C++ Graphics 3.0 4/10/2017 Borland Style Graphics for Dev C++) Mr. Dave Clausen La Cañada High School Mr. Dave Clausen

Turbo C++ Graphics 3.0 The Text Screen 4/10/2017 The text screen contains 25 lines with a capacity of holding 80 columns of textual characters. 80 X 25 = 2,000 positions But there are actually over 2,000 positions on a display screen. The screen consists of pixels (picture elements) that it uses to represent the textual characters and symbols. Mr. Dave Clausen Mr. Dave Clausen

Graphics Setup Here are the steps that you need to follow to use “Borland Style Graphics” source code in Dev C++: Tell the compiler that graphics commands will be used. Initialize the Graphics Screen Close the graphics screen after you have finished drawing your graphics. Mr. Dave Clausen

Graphics Setup 2 1) To tell the compiler that graphics commands will be used, include the preprocessor directive: #include <graphics.h> Mr. Dave Clausen

Graphics Setup 3 2) To initialize the graphics screen Turbo C++ Graphics 3.0 4/10/2017 Graphics Setup 3 2) To initialize the graphics screen initwindow(640,480); After you are finished drawing, you need to use the while(!kbhit()); command to leave the picture on the screen, or use cin.get(); The last choice requires: #include <iostream.h> 5) Then close the graphics screen, using: closegraph( ); Mr. Dave Clausen Mr. Dave Clausen

Fundamentals of Graphics The Graphics Screen. Color Options. Graphics Mode. Drawing Lines Line Style Clearing the Screen. Plotting Points. Mr. Dave Clausen

The Graphics Screen If you have a VGA graphics card or better in your computer, then the graphics screen has 640 pixels across and 480 pixels down. 640 X 480 = 307,200 pixels The upper left corner is position (0, 0) The lower right corner is position (639, 479) Remember, the computer starts counting with zero. Mr. Dave Clausen

The Graphics Screen Dimensions (0, 0) (639, 0) (0, 479) (639, 479) Mr. Dave Clausen

Background Color Options You can select the color of the background. This is done before drawing anything in the foreground (otherwise your drawing will disappear.) To select the background color use the command. setbkcolor(number); Where (number) is a numeric constant from 0 through 15, or the symbolic constant that represents the color. Mr. Dave Clausen

Turbo C++ Graphics 3.0 Color Options 4/10/2017 You select a foreground or “drawing” color by using the following command: setcolor(number); Where (number) is a numeric constant from 0 through 15, or the symbolic constant that represents the color. Mr. Dave Clausen Mr. Dave Clausen

Color Names Here are the color numbers and names: 0 = BLACK 1 = BLUE 2 = GREEN 3 = CYAN 4 = RED 5 = MAGENTA 6 = BROWN 7 = LIGHTGRAY 8 = DARKGRAY 9 = LIGHTBLUE 10 = LIGHTGREEN 11 = LIGHTCYAN 12 = LIGHTRED 13 = LIGHTMAGENTA 14 = YELLOW 15 = WHITE Mr. Dave Clausen

Drawing Lines The Current Pointer. The current pointer is an invisible pointer that keeps track of the current pixel position. It is the equivalent of the visible cursor in text mode. Mr. Dave Clausen

Turbo C++ Graphics 3.0 Drawing Lines 2 4/10/2017 To move the pointer to a location on the graph without drawing anything, use the command: moveto (X,Y); This is like PenUp (PU) in LOGO To draw lines from the current pointer’s position to another point on the graph, use the command: lineto (X,Y); This is like PenDown (PD) in LOGO or SetXY (x, y) grtmplte.cpp Mr. Dave Clausen Mr. Dave Clausen

Graphics Figures Lines Rectangles Circles Arcs Ellipses Points Mr. Dave Clausen

Lines, The Easy Way Instead of using the commands: moveto and lineto, we can draw a line using one command: line(x1, y1, x2, y2); The points (x1, y1) describe the beginning of the line, while (x2, y2) describes the endpoint of the line. The numbers x1, y1, x2, y2 are integers. Mr. Dave Clausen

Rectangles Rectangles can be drawn in different ways using lineto, moveto, moverel, and linerel. But an easier and faster way is using the Rectangle procedure which draws a rectangle in the default color and line style with the upper left at X1, Y1 and lower right X2, Y2. rectangle (x1, y1, x2, y2); Mr. Dave Clausen

Circles Circles can be drawn using the circle procedure. This draws a circle in the default color and line style with center at X, Y, radius in the X direction of Xradius, and corresponding Y radius. circle (x, y, radius); Mr. Dave Clausen

Arcs This procedure draws a circular arc in the default color and line style based upon a circle with center X, Y and given X radius. The arc begins at an angle of StartAngle and follows the circle to EndAngle. The angles are measured in degrees from 0 to 360 counter-clockwise where 0 degrees is directly right. arc ( x, y, startangle, endangle, radius); Mr. Dave Clausen

Visualizing Arcs Starting & Ending Angles Mr. Dave Clausen

Ellipses Draws an elliptical arc in the default color and line style based upon an ellipse with center X, Y and given radii. The arc begins at an angle to Start Angle and follows the ellipse to End Angle. The angles are measured in degrees from 0 to 360 counter-clockwise where 0 degrees is directly right. ellipse ( x, y, startangle , endangle, x_radius, y_radius); Mr. Dave Clausen

Plotting Points The Maximum value for X can be found using: getmaxx( ) The Maximum value for Y can be found using: getmaxy( ) To Plot a point: putpixel ( x_value, y_value, color); For example: putpixel (100, 100, WHITE); Mr. Dave Clausen

Sample Program Let’s look at a program with a line, rectangle, circle, arc, ellipse, and a point. Objects.cpp Mr. Dave Clausen

Line Style Setting the line style. All lines have a default line mode, but Turbo C++ allows the user to specify three characteristics of a line: style, pattern, and thickness. Use the command: setlinestyle (style, pattern, thickness); Mr. Dave Clausen

Line Style and Thickness Names Here are the names of the line styles and thickness: Line Style Thickness SOLID_LINE NORM_WIDTH DOTTED_LINE CENTER_LINE THICK_WIDTH DASHED_LINE USERBIT_LINE Mr. Dave Clausen

Line Style Patterns The names of the line patterns are: SOLID_LINE = 0 DOTTED_LINE = 1 CENTER_LINE = 2 DASHED_LINE = 3 Mr. Dave Clausen

Selecting Pattern and Color Filling Regions Getting a Pixel Filling Patterns Selecting Pattern and Color Filling Regions Getting a Pixel Mr. Dave Clausen

Selecting Pattern and Color Use the command SetFillStyle for setting the pattern and color for the object that you wish to fill. setfillstyle ( pattern, color); Mr. Dave Clausen

Pattern Names Here are the name of available patterns: Values Causing filling with EMPTY_FILL Background Color SOLID_FILL Solid Color LINE_FILL Horizontal Lines LTSLASH_FILL Thin diagonal lines SLASH_FILL Thick diagonal lines BKSLASH_FILL Thick diagonal backslashes LTBKSLASH_FILL Light backslashes HATCH_FILL Thin cross hatching XHATCH_FILL Thick cross hatching INTERLEAVE_FILL Interleaving lines WIDE_DOT_FILL Widely spaced dots CLOSE_DOT_FILL Closely spaced dots Mr. Dave Clausen

Filling Regions After selecting a color and pattern, floodfill is used to fill the desired area. floodfill ( x, y, border_color ); This “paints out” the desired color until it reaches border color. Note: The border color must be the same color as the color used to draw the shape. Also, you can only fill completely “closed” shapes. Program10_4.cpp Mr. Dave Clausen

Filling “Special” Regions To draw a filled ellipse: fillellipse ( xcoordinate, ycoordinate, xradius, yradius); To draw a filled rectangle: bar (x1, y1, x2, y2); To draw a filled 3D rectangle: bar3d(x1, y1, x2, y2, depth, topflag); //depth is width of the 3D rectangle, if topflag is non-0 a top is added to the bar To draw a filled section of a circle: pieslice (x, y, startangle, endangle, xradius); Mr. Dave Clausen

Text Output on the Graphics Screen To write a literal expression on the graphics screen using the location specified by (x, y) use the command: outtextxy (x, y, “literal expression”); outtextxy (x, y, string_variable); Note: These are not “apstring” type strings. They are C++ standard Strings. Mr. Dave Clausen

Text Styles To set the values for the text characteristics, use: settextstyle ( font, direction, charsize); Font Direction DEFAULT_FONT HORIZ_DIR = Left to right TRIPLEX_FONT VERT_DIR = Bottom to top SMALL_FONT SANS_SERIF_FONT Fonts continued GOTHIC_FONT COMPLEX_FONT SCRIPT_FONT EUROPEAN_FONT SIMPLEX_FONT BOLD_FONT TRIPLEX_SCR_FONT Mr. Dave Clausen

Text Styles Font Sizes 1 = Default (normal) 2 = Double Size CharSize 1 = Default (normal) 2 = Double Size 3 = Triple Size 4 = 4 Times the normal 5 = 5 Times the normal …. 10 = 10 Times the normal Mr. Dave Clausen

Text Justification To set the way that text is located around the point specified use the command: settextjustify (horizontal,vertical); Horizontal Vertical LEFT_TEXT TOP_TEXT CENTER_TEXT BOTTOM_TEXT RIGHT_TEXT Program10_2.cpp Mr. Dave Clausen

Clearing the Screen Here is the way to clear the graphics screen. Turbo C++ Graphics 3.0 Clearing the Screen 4/10/2017 Here is the way to clear the graphics screen. When in graphics mode use: cleardevice( ); //#include <graphics.h> Mr. Dave Clausen Mr. Dave Clausen

Text Height & Width Returns the height, in pixels, of string S if it were to be written on the graphics screen using the current defaults. textheight (S string); Returns the width, in pixels, of string S if it were to be written on the graphics screen using the current defaults. textwidth (S string); Mr. Dave Clausen

Getting a Pixel To return the color number corresponding to the color located at the point: X, Y use the command: getpixel (x, y); Mr. Dave Clausen

Useful Non Graphic Commands kbhit() checks to see if a keystroke is currently available If a keystroke is available, returns a nonzero integer. If a keystroke is not available, returns a zero. Any available keystrokes can be retrieved with getch(). Mr. Dave Clausen