Raptor

Páginas: 12 (2939 palabras) Publicado: 6 de noviembre de 2012
E. Graphics Programming with RAPTORgraph

By Dr. Steve Hadfield, Maj Jason Moore and Lt Col Tom Schorsch

In Computer Science 110, we will be creating graphics programs using a simple graphics package called RAPTORgraph, which was adapted from Adagraph written by Jerry van Dijk of the Netherlands and modified slightly for our use at USAFA. This reading explains how to get started usingRAPTORgraph, and it describes the RAPTORgraph routines you will need this semester.


Overview of RAPTORgraph


All RAPTORgraph commands are relative to a special graphics window, an example of which is depicted below (Figure 1). In this graphics window you can draw lines, rectangles, circles, arcs and ellipses of various sizes and colors. You can also display text in the graphics window. Ifyou are viewing this on-line, you can download and execute the program by clicking here: RaptorGraph_Image1.rap

[pic]
Figure 1. Example RAPTORgraph output

Several filled and unfilled graphic shapes have been drawn in the graphics window above. The green wire-frame “cylinder” was created by drawing two ellipses and then drawing a line between the tops the bottoms of the ellipses. The brownwire-frame “cube” was created by drawing two rectangles and then connecting the four corners of the rectangles with lines. The yellow, moon-shaped object right-of-center was created by flood-filling an enclosed area.

You can interact with a graphical program by determining the position of the mouse in the graphics window and determining if and where a mouse button was clicked. You can alsosimulate movement in the graphics window by drawing an object, erasing it (drawing it again in white – think “white-out”), and then redrawing the object in a slightly different position.


Getting Started with RAPTORgraph


To use RAPTORgraph, you must create a graphics window. This graphics window must be created prior to calling any other RAPTORgraph procedures or functions.Open_Graph_Window (X_Size, Y_Size)


If you used the above procedure call in your program, a graphics window 500 pixels wide by 300 pixels tall would be created. Such a graphics window is depicted in Figure 2 below.


[pic]
Figure 2. Graphics window coordinate system

The graphics window always starts off with a white background. The origin of the graphics window’s (X,Y) coordinate system is atthe bottom left-hand corner of the window. The X-axis starts from 1 going left to right. The Y-axis starts from 1 going bottom to top.


After your program is finished with all other graphic commands it should delete the graphic window with the following procedure call:


Close_Graph_Window


All other calls to RAPTORgraph procedures need to be between the calls that create and destroythe graphic window. The following example program (Figure 3) illustrates where the various commands are placed in your RAPTOR program (Simple Example.rap).

[pic]
Figure 3. Simple RAPTORgraph program


Graphics Output with RAPTORgraph


RAPTORgraph has a collection of procedures that draw shapes on the graphics window. All of these routines let the programmer specify the (X,Y)locations where the item is to appear in the graphic window.

For example, the Draw_Circle procedure can draw a filled circle that is centered at an (X,Y) coordinate in the graphics window and that has a particular radius and color.
Calls to Draw_Circle have the following format:

Draw_Circle( X, Y, Radius, Color, Filled)

Where X and Y are the horizontal and vertical positions of the circle'scenter point, Radius is the distance (in pixels) from the center point to the circle's edge, Color is the color of the circle, and Filled is either True/Filled or False/Unfilled. A value of True (or Filled) produces a solid circle, while a value of False (or Unfilled) only draws the circle's outside edge. For example,

Draw_Circle( 250, 150, 140, Blue, Filled)


produces a solid blue circle...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Raptor
  • raptor
  • Raptor
  • raptor
  • raptor
  • El Raptor
  • raptor
  • Raptor

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS