﻿ VIEWPORT

VIEWPORT，DEVICE WINDOW， DEVICE VIEWPORT

Let left, right, bottom, top be numeric expressions.
``` SET VIEWPORT left, right, bottom, top SET DEVICE WINDOW left, right, bottom, top SET DEVICE VIEWPORT left, right, bottom, top ```
When SET DEVICE VIEWPORT is executed, a device viewport shall be set on the graphics device.
The initial device viewport is the whole graphics device.
The unit of device viewport is a meter.

The SET DEVICE WINDOW statement sets the largest rectangle similar to the specified rectangle inside of the device viewport.
The initial device window is 0,1,0,1.
SET DEVICE VIEWPORT statements and SET DEVICE WINDOW statements erase the image.

The SET VIEWPORT statement assigns the rectangle where graphics statements work with respect to the device window coordinates.
The initial value of the viewport is 0,1,0,1. The four parameters of a SET DEVICE WINDOW or a SET VIEWORT is not less than 0 and not greater than 1.

SET VIEWPORT statements can be used for dividing the drawing pane into two or more sections.
SET VIEWPORT statements and SET WINDOW statements do not erase the image.

Example
Two graphs are drawn on the right upper section and the left lower section.

```100 OPTION ANGLE DEGREES
110 SET VIEWPORT 0.5, 1, 0.5, 1
120 SET WINDOW -4,4,-4,4
130 DRAW GRID
140 FOR x=-4 TO 4 STEP 0.01
150    PLOT LINES:x,x^3-3*x;
160 NEXT x
170 SET VIEWPORT 0,0.5 , 0,0.5
180 SET WINDOW -180,540,-4,4
190 DRAW GRID(90,1)
200 FOR x=-180 TO 540
210    PLOT LINES:x,SIN(x);
220 NEXT x
230 END```

``` SET CLIP "ON" SET CLIP "OFF" ``` If the clip is on, graphics is output on the intersection of the viewport and the device window.
If the clip is off, graphics is output on the device window.
The initial clip is on.

Let w, h be numeric variables, u\$ a string variable.
``` ASK DEVICE SIZE w, h, u\$ ``` assigns the width and the height of the device to w and h, "METERS" to u\$.
The unit of width and height is a meter.

Let l, r ,b ,t be numeric variables.
``` ASK DEVICE VIEWPORT l, r, b, t ASK DEVICE WINDOW l, r, b, t ASK VIEWPORT l, r, b, t ``` If the device is not square, an ASK DEVICE VIEWPORT statement can be used to inquire the actual aspect. This is the case the device is a printer.
Refer to Printers and metafiles