Home

Graphics Shapes and Primitives

The following subprograms provide the ability to draw shapes, lines, and other graphics primitives.

One concept to understand in this section is the existence of a “current position” of the graphics cursor on the screen. A handful of routines will use this in-memory screen coordinate for drawing. The moveto subroutine can be used to set the position directly. The graphics cursor, however, is never visible on the screen.

arc

C void arc (x, y, stangle, endangle, radius)
Fortran subroutine arc (x, y, stangle, endangle, radius)

Description

Draws a circular arc centered at (x,y) in the current color. The start angle, stangle, and end angle, endangle, are measured in degrees counterclockwise with 0 degrees at 3 o’clock.

Parameters

Parameter C Type Fortran Type Description
x int integer Horizontal center of the arc
y int integer Vertical center of the arc
stangle int integer Start angle of the arc in degrees
endangle int integer End angle of the arc in degrees
radius int integer Radius of the circular arc

bar

C void bar (left, top, right, bottom)
Fortran subroutine bar (left, top, right, bottom)

Description

Draws a rectangular, filled bar using the currently selected color and fill pattern.

Parameters

Parameter C Type Fortran Type Description
left int integer Leftmost horizontal bound of the bar
top int integer Topmost vertical bound of the bar
right int integer Righttmost horizontal bound of the bar
bottom int integer Bottommost vertical bound of the bar

bar3d

C void bar3d (left, top, right, bottom, depth, topflag)
Fortran subroutine bar3d (left, top, right, bottom, depth, topflag)

Description

Draws a three-dimensional rectangular, filled bar using the currently selected color and fill pattern. The bar is outlined using the current line color and style.

Parameters

Parameter C Type Fortran Type Description
left int integer Leftmost horizontal bound of the bar
top int integer Topmost vertical bound of the bar
right int integer Righttmost horizontal bound of the bar
bottom int integer Bottommost vertical bound of the bar
depth int integer The third-dimension depth of the bar
topflag int integer One to draw a top on the bar, zero to leave empty

circle

C void circle (x, y, radius)
Fortran subroutine circle (x, y, radius)

Description

Draws a circle centered at (x,y) with the given radius using the current color

Parameters

Parameter C Type Fortran Type Description
x int integer Horizontal center of the circle
y int integer Vertical center of the circle
radius int integer Radius of the circle

drawpoly

C void drawpoly (numpoints, points)
Fortran subroutine drawpoly (numpoints, points)

Description

Draws a polygon of numpoints points using the locations in points. In Fortran, the horizontal positions in the first column, and the vertical position in the second column. In C, the array is one-dimensional with the first horizontal position followed by the first vertical position followed by the second horizontal position, etc.

Parameters

Parameter C Type Fortran Type Description
numpoints int integer The number of points in the polygon
points int * integer, dimension(numpoints, 2) Points of the polygon (see description)

ellipse

C void ellipse (x, y, stangle, endangle, xradius, yradius)
Fortran subroutine ellipse (x, y, stangle, endangle, xradius, yradius)

Description

Draws an ellipse centered at (x,y) with the given radius using the current color. The start angle, stangle, and end angle, endangle, are measured in degrees counterclockwise with 0 degrees at 3 o’clock.

Parameters

Parameter C Type Fortran Type Description
x int integer Horizontal center of the ellipse
y int integer Vertical center of the ellipse
stangle int integer Start angle of the arc in degrees
endangle int integer End angle of the arc in degrees
xradius int integer Radius along the horizontal axis
yradius int integer Radius along the vertical axis

fillellipse

C void fillellipse (x, y, xradius, yradius)
Fortran subroutine fillellipse (x, y, xradius, yradius)

Description

Draws a filled ellipse centered at (x,y) with the given radius using the current color.

Parameters

Parameter C Type Fortran Type Description
x int integer Horizontal center of the ellipse
y int integer Vertical center of the ellipse
xradius int integer Radius along the horizontal axis
yradius int integer Radius along the vertical axis

fillpoly

C void fillpoly (numpoints, points)
Fortran subroutine fillpoly (numpoints, points)

Description

Draws a filled polygon of numpoints points using the locations in points. In Fortran, the horizontal positions in the first column, and the vertical position in the second column. In C, the array is one-dimensional with the first horizontal position followed by the first vertical position followed by the second horizontal position, etc.

Parameters

Parameter C Type Fortran Type Description
numpoints int integer The number of points in the polygon
points int * integer, dimension(numpoints, 2) Points of the polygon (see description)

floodfill

C void floodfill (x, y, border)
Fortran subroutine floodfill (x, y, border)

Description

Fills in the screen starting at point (x,y) until the color border is encountered.

Parameters

Parameter C Type Fortran Type Description
x int integer Horizontal point at which to start flood fill operation
y int integer Vertical point at which to start flood fill operation
border int integer Color at which flood fill is stopped

getarccoords

C void getarccoords ( arccoords )
Fortran subroutine getarccoords ( arccoords )

Description

Retrieves the arc coordinates used for the latest arc drawing request.

Parameters

Parameter C Type Fortran Type Description
arccoords arccoordstype * type(arccoordstype), intent(out) Pointer to the structure to fill with the arc details

getpixel

C int getpixel ( x, y )
Fortran function getpixel ( x, y )

Description

Retrieves the color as an RGB triplet at the pixel at the specified coordinates

Parameters

Parameter C Type Fortran Type Description
x int integer Horizontal point at which to query the pixel color
y int integer Vertical point at which to query the pixel color

Return Value

C int
Fortran integer

The color of the pixel as an RGB triplet

getx

C int getx ( )
Fortran function getx ( )

Description

Retrieves the current horizontal graphics cursor position

Return Value

C int
Fortran integer

The horizontal position of the graphics cursor

gety

C int gety ( )
Fortran function gety ( )

Description

Retrieves the current vertical graphics cursor position

Return Value

C int
Fortran integer

The vertical position of the graphics cursor

line

C void line (x1, y1, x2, y2)
Fortran subroutine line (x1, y1, x2, y2)

Description

Draws a line using the current color from point (x1,y1) to point (x2,y2).

Parameters

Parameter C Type Fortran Type Description
x1 int integer Horizontal coordinate of the start point of the line
y1 int integer Vertical coordinate of the start point of the line
x2 int integer Horizontal coordinate of the end point of the line
y2 int integer Vertical coordinate of the end point of the line

linerel

C void linerel (dx, dy)
Fortran subroutine linerel (dx, dy)

Description

Draws a line from the current position to a point that is distanced dx horizontally and dy vertically from the current position using the current color. The current position is moved to this new offset after the drawing operation.

Parameters

Parameter C Type Fortran Type Description
dx int integer Horizontal offset of the end point of the line
dy int integer Vertical offset of the end point of the line

lineto

C void lineto (x, y)
Fortran subroutine lineto (x, y)

Description

Draws a line from the current position to the point (x, y) using the current color. The current position is moved to this new offset after the drawing operation.

Parameters

Parameter C Type Fortran Type Description
x int integer Horizontal coordinate of the end point of the line
y int integer Vertical coordinate of the end point of the line

moverel

C void moverel ( int dx, int dy )
Fortran subroutine moverel ( int dx, int dy )

Description

Moves the graphics cursor a specifed distance in the horizontal and vertical positions from the current position.

Parameters

Parameter C Type Fortran Type Description
dx int integer Horizontal distance relative to the current position
dy int integer Vertical distance relative to the current position

moveto

C void moveto (x, y)
Fortran subroutine moveto (x, y)

Description

Sets the current position to be used with subsequent relative graphics operations.

Parameters

Parameter C Type Fortran Type Description
x int integer Horizontal coordinate of the current position
y int integer Vertical coordinate of the current position

pieslice

C void pieslice (x, y, stangle, endangle, radius)
Fortran subroutine pieslice (x, y, stangle, endangle, radius)

Description

Draws a filled circular arc centered at (x,y) in the current color, appearing in the shape of a pie slice. The start angle, stangle, and end angle, endangle, are measured in degrees counterclockwise with 0 degrees at 3 o’clock.

Parameters

Parameter C Type Fortran Type Description
x int integer Horizontal center of the arc
y int integer Vertical center of the arc
stangle int integer Start angle of the arc in degrees
endangle int integer End angle of the arc in degrees
radius int integer Radius of the circular arc

putpixel

C void putpixel (x, y, color)
Fortran subroutine putpixel (x, y, color)

Description

Draws a single pixel at (x, y) using the color color.

Parameters

Parameter C Type Fortran Type Description
x int integer Horizontal coordinate of the pixel
y int integer Vertical coordinate of the pixel
color int integer The color of the pixel

rectangle

C void rectangle (left, top, right, bottom)
Fortran subroutine rectangle (left, top, right, bottom)

Description

Draws an unfilled rectangle with vertices located at (left, top) and (right, bottom)

Parameters

Parameter C Type Fortran Type Description
left int integer Leftmost horizontal bound of the rectangle
top int integer Topmost vertical bound of the rectangle
right int integer Righttmost horizontal bound of the rectangle
bottom int integer Bottommost vertical bound of the rectangle

sector

C void sector (x, y, stangle, endangle, xradius, yradius)
Fortran subroutine sector (x, y, stangle, endangle, xradius, yradius)

Description

Draws a filled elliptical shape, similar to a pie slice, centered at (x,y) with the given radius using the current color. The start angle, stangle, and end angle, endangle, are measured in degrees counterclockwise with 0 degrees at 3 o’clock.

Parameters

Parameter C Type Fortran Type Description
x int integer Horizontal center of the sector
y int integer Vertical center of the sector
stangle int integer Start angle of the arc in degrees
endangle int integer End angle of the arc in degrees
xradius int integer Radius along the horizontal axis
yradius int integer Radius along the vertical axis