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.

drawpoly

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

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.

fillpoly

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.

getarccoords

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 )Fortranfunctiongetpixel ( 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

CintFortraninteger

The color of the pixel as an RGB triplet

getx

C int getx ( )Fortranfunctiongetx ( )

Description

Retrieves the current horizontal graphics cursor position

Return Value

CintFortraninteger

The horizontal position of the graphics cursor

gety

C int gety ( )Fortranfunctiongety ( )

Description

Retrieves the current vertical graphics cursor position

Return Value

CintFortraninteger

The vertical position of the graphics cursor

line

C void line (x1, y1, x2, y2)Fortransubroutineline (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)Fortransubroutinelinerel (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)Fortransubroutinelineto (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.

pieslice

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.

sector

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.