Printers and MetaFile

Option Menu - Graphics enables us to create a metafile or send graphics command directly to the printer.

1. Setting Printer
Before the execution of the program, set up the printer.
On the Option Menu - Graphics dialog, click Printer Setting button and select the printer and the paper.

2. About the default drawing pane
When Image Format MetaFile(Printer) or Printer(direct) is selected, the default drawing pane is the largest square contained in the printable area and containing the left-bottom end of the printable area.

3. Alteration of drawing pane
(1) Alternation of aspect ratio
The following code changes the drawing pane into the rectangle of which the ratio of the height to the width is 4 : 3, on the assumption that the Paper Orientation is portrait.

140 SET DEVICE WINDOW 0, 3/4, 0, 1
150 SET VIEWPORT      0, 3/4, 0, 1
160 SET WINDOW  -3, 3,  -4, 4
170 DRAW grid
180 DEF f(x)=x*(x-1)*(x+1)
190 FOR x=-3 TO 3 STEP 0.01
200    PLOT LINES: x,f(x);
210 NEXT x
220 END

In order to use the rectangle of which the ratio of the width to the height is 3:4, execute a SET DEVICE WINDOW statement and a SET VIEWPORT statement with the parameters 0, 3/4, 0, 1.
When the Paper Orientation is landscape, to change the ratio of the height to width into 3 : 4, for example, modify the lines as follows.

140 SET DEVICE WINDOW 0, 1, 0, 3/4
150 SET VIEWPORT      0, 1, 0, 3/4

(2) Additional Margin
Shrinking device viewport enlarges margins.
For example, the following enlarges the left, right, top, bottom margins by 1cm each.

120 ASK DEVICE VIEWPORT dvleft,      dvright,      dvbottom,      dvtop
130 SET DEVICE VIEWPORT dvleft+0.01, dvright-0.01, dvbottom+0.01, dvtop-0.01

(Note.) The measure of the device viewport is a meter when the Image Format is a metafile or the printer.

(3) Designation of a size
If you need the drawing pane of width w(mm) and height h(mm) , use the following codes if w>h.

ASK DEVICE VIEWPORT dvleft, dvright,         dvbottom, dvtop
SET DEVICE VIEWPORT dvleft, dvleft + w/1000, dvbottom, dvbottom + h/1000
SET DEVICE WINDOW 0, 1, 0, h/w
SET VIEWPORT      0, 1, 0, h/w

On the case of w<h, the last 2 lines should be altered as follows.

SET DEVICE WINDOW 0, w/h, 0, 1 
SET VIEWPORT      0, w/h, 0, 1 

4. Supplement
(1) ASK DEVICE SIZE w,h,s$
  assigns the width, the height of the printable area to numeric variables w, h and "meters" to a string variable s$. The measure is a meter.
(2) The following statement returns a meaning value. The measure is a pixel.
(3) The following statements return -1. Note that they do not cause an exception.
(4) The following statements cause exceptions.
(5) When the Image Format is Printer(direct), execution of CLEAR makes a page feed.

Refer to Option Menu - Graphics