Skip to main content

Window

Window (Statement)​

Format​

window x1, y1, x2, y2
window ( x1, y1, x2, y2 )
window

Description​

Gives the graphics area coordinates of your own choosing. x1,y1 becomes the top left corner of the drawing area and x2,y2 the bottom right corner. Every drawing statement then works in those units instead of in pixels, so window -1,-1,1,1 puts 0,0 in the middle of the screen.

window with no arguments goes back to plain pixels. That is the state a program starts in, and it behaves exactly as if you had said window 0, 0, GraphWidth, GraphHeight.

The order of the arguments chooses which way each axis runs, because y1 is always at the top and y2 always at the bottom:

window -1,-1,1,1y increases downwards, the way the screen normally works
window -1,1,1,-1y increases upwards, the way graph paper works

The same is true of x, so window 1,-1,-1,1 runs x from right to left.

Pixel, MouseX, MouseY, ClickX and ClickY read back in the same units, so you can find again what you drew.

PenWidth and Font keep their sizes in pixels. A line does not become thicker, and lettering does not become larger, just because the window makes a unit big.

A picture keeps its size in pixels for the same reason. Imgload, GetSlice and PutSlice take their position in window units, but the image or the slice is painted at the size it really is. Use the scale argument of Imgload to paint a picture larger or smaller.

The window belongs to whatever you are drawing on, so it follows SetGraph onto an image and back again. The same window -1,-1,1,1 covers a small image and the whole graphics area alike.

A window that is not the same shape as the graphics area stretches what you draw, so a Circle comes out as an oval. A window with no width or no height is an error.

Example​

graphsize 300,300
clg
window -1.5, 1.5, 1.5, -1.5

color black
line -1.5, 0, 1.5, 0
line 0, -1.5, 0, 1.5

color red, clear
penwidth 2
circle 0, 0, 1

color blue
penwidth 1
for a = -1.5 to 1.5 step 0.005
plot a, sin(a * 3) * 0.7
next a

draws
Window

The circle has a radius of 1 and the curve runs from -1.5 to 1.5, with 0,0 in the middle and y increasing upwards. Nothing in the program needs to know how many pixels wide the graphics area is.

See Also​

Arc, Chord, Circle, ClickX, ClickY, Font, GetSlice, GraphSize, Imgload, Line, MouseX, MouseY, PenWidth, Pie, Pixel, Plot, Poly, PutSlice, Rect, SetGraph, Stamp, Text

History​

2.1.2New To Version
2.3Imgload, GetSlice and PutSlice follow the window