Skip to content

Commit e0f96c4

Browse files
authored
Update 624-graphics-window.markdown
1 parent f1edad7 commit e0f96c4

File tree

1 file changed

+42
-30
lines changed

1 file changed

+42
-30
lines changed

_build/reference/624-graphics-window.markdown

Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
11
# WINDOW
22

3-
> WINDOW [x1,y2,x2,y1]
3+
> WINDOW [x1, x2, y2, y1]
44
5-
Specifies "world" coordinates for the screen.
5+
Specifies "world" coordinates for the screen. The WINDOW command allows you to redefine the corners of the display screen as a pair of "world" coordinates. The coordinates of the upper-left corner of the screen is given by `[x1, y1]`, the lower-left corner by `[x2, y2]`.
66

7-
The WINDOW command allows you to redefine the corners of the display screen as a pair of "world" coordinates.
7+
The world space defined by WINDOW is disabled by a WINDOW command without parameters.
88

9-
The world space defined by WINDOW is disabled by a WINDOW command with no parameters.
10-
11-
Note: the unusal coordinates are intended for Quick BASIC compatibility (possible bug).
9+
### Example
1210

1311
```
14-
window 1, 320, 320, 1
15-
rect 0, 0, 160, 160, 1 filled
16-
rect 160, 160, 320, 320, 2 filled
17-
rect 160, 0, 320, 160, 3 filled
18-
rect 0, 160, 160, 320, 4 filled
12+
' Coordinate system with corners:
13+
' upper-left = [-20,-10]
14+
' lower-right= [ 20, 10]
15+
x1 = -20
16+
y1 = -10
17+
x2 = 10
18+
y2 = 20
19+
20+
window x1, x2, y2, y1
21+
22+
rect -20, -10 STEP 1, 1, 14 filled ' Yellow: upper-left
23+
rect 19, -10 STEP 1, 1, 13 filled ' Magenta: upper-right
24+
rect 19, 9 STEP 1, 1, 12 filled ' Red: lower-right
25+
rect -20, 9 STEP 1, 1, 10 filled ' Green: lower-left
26+
circle 0, 0, 1, 1, 15 filled ' White: center
1927
```
2028

2129
## WINDOW sub-commands (non-standard)
@@ -24,7 +32,7 @@ WINDOW is also overloaded as a function, returning a system object which provide
2432

2533
### alert(message, title)
2634

27-
Display an alert message.
35+
Display an alert window. The title of the window is `title` and the context is `message`.
2836

2937
```
3038
w = window()
@@ -33,45 +41,49 @@ w.alert("This is an alert", "title")
3341

3442
### ask(message, title)
3543

36-
Display a prompt to retrieve a user selection.
44+
Display a prompt window to retrieve a user selection. The choices are "Yes" and "No". The title of the window is `title` and the context is `message`. The answer is stored in the window-object variable `answer`: `0` for "Yes" and `1` for "No".
3745

3846
```
3947
w = window()
48+
4049
w.ask("Yes or no?", "Question")
50+
4151
if w.answer == 0 then
42-
w.alert("Yes!", "Answer")
52+
print "Yes"
4353
else
44-
w.alert("No", "Answer")
54+
print "No"
4555
endif
4656
```
4757

4858
### graphicsScreen1(), graphicsScreen2()
4959

50-
Select graphics mode screen 1 or 2 for output.
60+
Select graphics mode screen 1 or 2 for output. When switching to a different screen, the context of the previous screen is stored in RAM. When switching back to the previous screen, the context will be restored.
5161

5262
```
53-
dim v(30)
54-
for i = 0 to 30
55-
v[i] = rnd
56-
next i
63+
w = window()
5764
58-
sub draw_chart(n,s)
59-
color 1,15: cls
60-
chart n, v, s, 1, 1, xmax-2, ymax-2
61-
end
65+
w.graphicsScreen1() ' Set output to screen 1
66+
rect 100,100 STEP 100,100, 15 filled
6267
63-
w = window()
64-
w.graphicsScreen2(): draw_chart(1, 5)
65-
w.graphicsScreen1(): draw_chart(2, 3)
68+
w.graphicsScreen2() ' Set output to screen 2
69+
rect 150,150 STEP 100,100, 14 filled
6670
71+
' Switch between both screens, no need to redaw the rectangles
6772
while 1
68-
b = !b
69-
if b then w.graphicsScreen1() else w.graphicsscreen2()
70-
pause
73+
b = !b
74+
if b then
75+
w.graphicsScreen1()
76+
else
77+
w.graphicsscreen2()
78+
endif
79+
delay(500)
7180
wend
7281
```
82+
7383
### insetTextScreen(x, y, w, h)
7484

85+
Insert an area for text output at position `[x, y]` with width `w` and height `h`
86+
7587
```
7688
w = window()
7789
? "How does this look?"

0 commit comments

Comments
 (0)