Skip to content

Commit 75c7154

Browse files
authored
Update 614-graphics-color.markdown
1 parent 21229a3 commit 75c7154

1 file changed

Lines changed: 38 additions & 28 deletions

File tree

_build/reference/614-graphics-color.markdown

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,68 +2,78 @@
22

33
> COLOR foreground-color [, background-color]
44
5-
Specifies the foreground and background colors.
5+
Specifies the foreground color `foreground-color` and the optinal background color `background-color`.
66

77
See RGB and RGBF to create colors.
88

9-
Example 1: Assigning SmallBASIC standard colors to text
9+
### Example 1
1010

11-
~~~
11+
```
12+
color 14, 1
13+
print "Yellow text on blue background"
14+
```
15+
16+
### Example 2: Assigning SmallBASIC standard colors to text
17+
18+
```
1219
For back = 0 To 7 Do
1320
text = back Xor 15 ' count down text color (15 to 8)
1421
1522
Color text, back
16-
Print Using " text_, back COLOR ##, ## "; text, back;
23+
Print Using " FG and BG COLOR: ##, ## "; text, back;
1724
1825
Color back, text ' reverse colors
19-
Print Using " text_, back COLOR ##, ## "; back, text
26+
Print Using " FG and BG COLOR: ##, ## "; back, text
2027
Next
21-
~~~
22-
23-
Example 2: Assigning RGB-colors to text
28+
```
2429

25-
~~~
30+
### Example 3: Assigning RGB-colors to text
2631

32+
```
2733
Print "Try color printing with some RGB shades"
2834
Print
2935
For shade = 0 To 10
30-
text = rgb(shade*25,0,0)
31-
back=rgb(255-shade*25,255-shade*25,255-shade*25)
36+
text = rgb(shade * 25, 0, 0)
37+
back = rgb(255 - shade * 25, 255 - shade * 25, 255 - shade * 25)
38+
3239
Color text, back
33-
Print "Here is black to red on white to black ";shade*25;",";255-25*shade
40+
41+
Print "Here is black to red on white to black "; shade * 25; ","; 255 - 25 * shade
3442
3543
Color back, text ' reverse colors
36-
Print "Here is reverse white to black on black to red."
44+
45+
Print "Here is reverse white to black on black to red."
3746
print
3847
Next
39-
Pause
40-
~~~
48+
```
4149

42-
Example 3: Using RGB and RGBF to draw a magenta filled rectangle with white boarder
50+
### Example 4: Using RGB and RGBF to draw a magenta filled rectangle with white boarder
4351

4452
```
45-
color rgb(255,67,133)
53+
color rgb(255, 67, 133)
4654
rect 10, 10, 100, 100 filled ' filling always with foreground color
4755
48-
color rgbf(1,1,1)
56+
color rgbf(1, 1, 1)
4957
rect 10, 10, 100, 100
5058
```
5159

52-
Here is a chart of the 16 SmallBASIC standard colors and their numbers:
60+
### Example 5: Chart of the 16 SmallBASIC standard colors and their numbers
5361

54-
~~~
62+
```
5563
' Color chart of the 16 SmallBASIC standard colors
5664
' for 0 = black to 15 = bright white
57-
dy=ymax/16
58-
for i=0 to 15
59-
rect 0,i*dy,xmax,i*dy+dy,i filled
60-
at 0,i*dy:? i;
65+
dy = ymax / 16
66+
for i = 0 to 15
67+
rect 0, i * dy, xmax, i * dy + dy, i filled
68+
at 0, i * dy : print i;
6169
next
62-
~~~
70+
```
71+
72+
### Example 6
6373

64-
You may Include "color_const.bas" file in another file to make your code more clear.
74+
You may include "color_const.bas" file in another file to make your code more clear.
6575

66-
~~~
76+
```
6777
' demo - add these lines to another BAS file:
6878
' ------------------------------------------
6979
' Include "color_const.bas" ' actuall filename must be lower case for Linux.
@@ -88,6 +98,6 @@ Const BRIGHT_RED = 12
8898
Const BRIGHT_MAGENTA = 13
8999
Const YELLOW = 14
90100
Const BRIGHT_WHITE = 15
91-
~~~
101+
```
92102

93103

0 commit comments

Comments
 (0)