WINDOW Statement


To draw lines, graphics, and objects in space not bounded by the physical  limits of the screen.




(x1,y1), (x2,y2) are the coordinates defined by the user. These coordinates, called the world coordinates, may be any single-precision, floating-point number. They define the world coordinate space that graphics statements map into the physical coordinate space, as defined by the VIEW statement.

WINDOW is the rectangular region in the world coordinate space. It allows zoom and pan. It allows the user to draw lines, graphics, and objects in space not bounded by the physical limits of the screen. To do this the user specifies the world coordinate pairs (x1,y1) and (x2,y2.) GW-BASIC then converts the world coordinate pairs into the appropriate physical coordinate pairs for subsequent display within screen space.

Window inverts, with the screen attribute omitted, the y coordinate on subsequent graphics statements. This places the (x1,y1) coordinate in the lower-left and the (x2,y2) coordinate in the upper-right of the screen. This allows the screen to be viewed in true Cartesian coordinates.

The coordinates are not inverted when the SCREEN attribute is included. This places the (x1,y1) coordinate in the upper-left and the (x2,y2) coordinate in the lower-right corner of the screen.

The WINDOW statement sorts the x and y argument pairs into ascending order. For example:

WINDOW (50, 50)-(10, 10)
WINDOW (10, 10)-(50, 50)


WINDOW (-2, 2)-(2, -2)
WINDOW (-2, -2)-(2, 2)

All coordinate pairs of x and y are valid, except that x1 cannot equal x2 and y1 cannot equal y2.

WINDOW with no arguments disables previous window statements.

Example 1:

If you type:


the screen uses the standard coordinate attributes:

(0, 0)           (320, 0)         (639, 0)
  ↓ y increases
                (320, 100)

(0, 199)        (320, 199)      (639, 199)

Example 2:

If you type:

WINDOW (-1, -1)-(1, 1)

the screen uses the Cartesian coordinates:

(-1, 1)           (0, 1)            (1, 1)
  ↑ y increases
                  (0, 0)
  ↓ y decreases
(-1, -1)          (0, -1)           (1, -1)

Example 3:

If you type:

WINDOW SCREEN (-1, -1)-(1, 1)

the screen uses the non-inverted coordinate:

(-1, -1)          (0, -1)           (1, -1)
 ↑ y decreases
                  (0, 0)
 ↓ y increases
(-1, 1)           (0, 1)            (1, 1)

RUN, SCREEN, and WINDOW with no attributes disable any WINDOW definitions and return the screen to its normal physical coordinates.