Colors

The color commands assign colors to the background of the Graphics canvas, or the turtle pen. A color is one of three things: A number between 0 and 137 for the 138 Web colors, a color name (which is one of 138 standard Web color names, see COLORS), or a list of four values, one each for Red, Green, and Blue. These three values may vary from 0 to 255.

The fourth value is optional and describes how transparent a color should be. A value of 0 makes the color invisible, and a value of 1 makes it opaque. This value is also referred to as a color's alpha value.

Color indexes and color names do not have an own alpha value. Instead, their alpha value is set to 1 (fully opaque), unless you use a turtle command. In that case, the turtle's alpha value (which you set with the SETALPHA command) is returned as the alpha value of a color name or color index. If you use a color name to work with the background, a value of 1 (fully opaque) is used. The same happens if you supply a list of three color values without an alpha value; for commands related to a turtle, the turtle's alpha value is used; for all other purposes, an alpha value of 1 is used. See the SETALPHA command for a few examples.

Logo color names are the same as the standard Web color names. These color names go back a long way to the first graphic subsystems based on the X11 architecture in 1986. Nowadays, every Web browser understands these color names.

The tables below display the color names along with their color index and the RGB values, which are the intensities of the Red, Green and Blue components of a color, expressed as values between 0 and 255.

The following commands would all set the pen color to Gold:

SETPC "GOLD
SETPC 60
SETPC [255 215 0]
SETPC [255 215 0 1]

If you want to use a transparent gold, you can use a four-element list as in this example, with the alpha value set to 0.5:

SETPC [255 215 0 0.5]
Name Index RGB values
Pink colors
Pink 112 255 192 203
LightPink 77 255 182 193
HotPink 63 255 105 180
DeepPink 50 255 20 147
PaleVioletRed 108 219 112 147
MediumVioletRed 94 199 21 133
Red colors
LightSalmon 78 255 160 122
Salmon 118 250 128 114
DarkSalmon 44 233 150 122
LightCoral 73 240 128 128
IndianRed 64 205 92 92
Crimson 32 220 20 60
FireBrick 54 178 34 34
DarkRed 43 139 0 0
Red 12 255 0 0
OrangeRed 103 255 69 0
Tomato 132 255 99 71
Coral 29 255 127 80
DarkOrange 41 255 140 0
Orange 102 255 165 0
Yellow colors
Yellow 14 255 255 0
LightYellow 83 255 255 224
LemonChiffon 71 255 250 205
LightGoldenrodYellow 75 250 250 210
PapayaWhip 109 255 239 213
Moccasin 98 255 228 181
PeachPuff 110 255 218 185
PaleGoldenrod 105 238 232 170
Khaki 67 240 230 140
DarkKhaki 38 189 183 107
Gold 59 255 215 0
Brown colors
Cornsilk 31 255 248 220
BlanchedAlmond 22 255 235 205
Bisque 21 255 228 196
NavajoWhite 99 255 222 173
Wheat 135 245 222 179
BurlyWood 25 222 184 135
Tan 130 210 180 140
RosyBrown 115 188 143 143
SandyBrown 119 244 164 96
Goldenrod 60 218 165 32
DarkGoldenrod 35 184 134 11
Peru 111 205 133 63
Chocolate 28 210 105 30
SaddleBrown 117 139 69 19
Sienna 122 160 82 45
Brown 24 165 42 42
Maroon 4 128 0 0
Color name Index RGB values
Green colors
DarkOliveGreen 40 85 107 47
Olive 6 128 128 0
OliveDrab 101 107 142 35
YellowGreen 137 154 205 50
LimeGreen 84 50 205 50
Lime 10 0 255 0
LawnGreen 70 124 252 0
Chartreuse 27 127 255 0
GreenYellow 61 173 255 47
SpringGreen 128 0 255 127
MediumSpringGreen 92 0 250 154
LightGreen 76 144 238 144
PaleGreen 106 152 251 152
DarkSeaGreen 45 143 188 143
MediumSeaGreen 90 60 179 113
SeaGreen 120 46 139 87
ForestGreen 56 34 139 34
Green 2 0 128 0
DarkGreen 37 0 100 0
Cyan colors
MediumAquamarine 86 102 205 170
Cyan (Aqua) 11 0 255 255
LightCyan 74 224 255 255
PaleTurquoise 107 175 238 238
Aquamarine 18 127 255 212
Turquoise 133 64 224 208
MediumTurquoise 93 72 209 204
DarkTurquoise 48 0 206 209
LightSeaGreen 79 32 178 170
CadetBlue 26 95 158 160
DarkCyan 34 0 139 139
Teal 3 0 128 128
Blue colors
LightSteelBlue 82 176 196 222
PowderBlue 114 176 224 230
LightBlue 72 173 216 230
SkyBlue 124 135 206 235
LightSkyBlue 80 135 206 250
DeepSkyBlue 51 0 191 255
DodgerBlue 53 30 144 255
CornflowerBlue 30 100 149 237
SteelBlue 129 70 130 180
RoyalBlue 116 65 105 225
Blue 9 0 0 255
MediumBlue 87 0 0 205
DarkBlue 33 0 0 139
Navy 1 0 0 128
MidnightBlue 95 25 25 112
Color name Index RGB values
Purple colors
Lavender 68 230 230 250
Thistle 131 216 191 216
Plum 113 221 160 221
Violet 134 238 130 238
Orchid 104 218 112 214
Magenta (Fuchsia) 13 255 0 255
MediumOrchid 88 186 85 211
MediumPurple 89 147 112 219
BlueViolet 23 138 43 226
DarkViolet 49 148 0 211
DarkOrchid 42 153 50 204
DarkMagenta 39 139 0 139
Purple 5 128 0 128
Indigo 65 75 0 130
DarkSlateBlue 46 72 61 139
SlateBlue 125 106 90 205
MediumSlateBlue 91 123 104 238
White colors
White 15 255 255 255
Snow 127 255 250 250
Honeydew 62 240 255 240
MintCream 96 245 255 250
Azure 19 240 255 255
AliceBlue 16 240 248 255
GhostWhite 58 248 248 255
WhiteSmoke 136 245 245 245
Seashell 121 255 245 238
Beige 20 245 245 220
OldLace 100 253 245 230
FloralWhite 55 255 250 240
Ivory 66 255 255 240
AntiqueWhite 17 250 235 215
Linen 85 250 240 230
LavenderBlush 69 255 240 245
MistyRose 97 255 228 225
Gray/Black colors
Gainsboro 57 220 220 220
LightGray 7 211 211 211
Silver 123 192 192 192
DarkGray 36 169 169 169
Gray 8 128 128 128
DimGray 52 105 105 105
LightSlateGray 81 119 136 153
SlateGray 126 112 128 144
DarkSlateGray 47 47 79 79
Black 0 0 0 0

ALPHA

Reports the first active turtle's alpha value.

Syntax

ALPHA

Description

ALPHA reports the first active turtle's alpha value. The turtle uses the alpha value to fill in the alpha value for color names, or three-element color lists that do not have an alpha value.

Example

ALPHA
Result: 1

BACKGROUND (BG)

Reports the background color.

Syntax

BACKGROUND

Description

BACKGROUND reports a list of RGB values that represents the current background color of the Graphics canvas. The initial background color is a fully transparent white so background images are fully visible.

For an explanation of how background patterns and images play together, see LOADPIC.

Example

MAKE "MY.BG BG
SETBG "LIME
SETBG :MY.BG

COLOR

Reports the RGB color value for a color name or color index.

Syntax

COLOR "color-name
COLOR color-index

Description

COLOR reports the color value for the color name or color index that it received as input.

See also COLORNAME and COLORINDEX.

Example

COLOR "GOLD
Result: [255 215 0 1]

COLORINDEX (BASECOLOR)

Coerces a color value to a basic Logo color number.

Syntax

COLORINDEX "color-name
COLORINDEX [red green blue]

Description

COLORINDEX takes a color name (which is one of 138 standard Web color names, see COLORS), or a list of up to four values, one each for Red, Green, and Blue, plus an optional alpha value. The color values may vary from 0 to 255, and the alpha value is between 0 and 1. COLORINDEX maps this color to one of the Web colors used by Logo, and reports the number of that color. If Logo cannot match the color, it reports the value -1.

See also COLORNAME and COLOR.

Example

COLORINDEX [255 165 0]
Result: 102
COLORINDEX "ORANGE
Result: 102

BGPATTERN

Reports the background pattern.

Syntax

BGPATTERN

Description

BGPATTERN reports a number that represents the current background pattern of the graphics screen. To set the background pattern of the graphics screen, use SETBGPATTERN. To see a list of predefined patterns, see SETPATTERN. Pattern 0 is an all-on pattern. If you set that pattern, SETBG sets solid colors, hiding any background image.

If a list or the name of an object was used as input to SETBGPATTERN, BGPATTERN reports that value.

For an explanation of how background patterns and images play together, see LOADPIC.

COLOR

Reports the color for a name or value if possible.

Syntax

COLOR color-index
COLOR [red green blue]
COLOR "color-name

Description

COLOR takes takes a color name (which is one of 138 standard Web color names, see COLORS), or a list of up to four values, one each for Red, Green, and Blue, plus an optional alpha value. The color values may vary from 0 to 255, and the alpha value is between 0 and 1. COLOR attempts to match the input to a table of known color names, ignoring the alpha value. If a match is found, COLOR outputs the corresponding four-element list of color values, with an alpha value of 1. If COLOR cannot match the color, it reports FALSE. If the input is a number between 0 and 137, COLOR reports the color values for the respective standard color as described in SETPC. If the input is a list of color values, COLOR reports that list.

See also COLORNAME and COLORS.

Example

COLOR "SANDYBROWN
Result: [244 164 96 1]
COLOR 67
Result: [240 230 140 1]

COLORNAME

Reports the name of a color if possible.

Syntax

COLORNAME color-value
COLORNAME [red green blue]

Description

COLORNAME takes a color name (which is one of 138 standard Web color names, see COLORS), or a list of up to four values, one each for Red, Green, and Blue, plus an optional alpha value. The color values may vary from 0 to 255, and the alpha value is between 0 and 1. COLORNAME attempts to match its input to a known color name, ignoring the alpha value. If Logo cannot match the color, it reports FALSE.

See also COLOR and COLORS.

Example

COLORNAME [245 222 179]
Result: WHEAT

COLORS

Reports a list of available color names.

Syntax

COLORS

Description

COLORS reports a list of available color words that can be used in place of color numbers or lists of RGB values. The names in this list correspond to the standard 138 Web color names. See also COLOR and COLORNAME.

Example

COUNT COLORS
Result: 138

PATTERN

Reports the turtle's pattern.

Syntax

PATTERN

Description

PATTERN reports a number that represents the current fill pattern of the first active turtle. To set the fill pattern of the graphics screen, use SETBGPATTERN. To see a list of predefined fill patterns, see SETPATTERN; this command also lets you set a turtle's fill pattern.

Example

SETPC 4
SETPATTERN 2
(STAMPRECT 100 100 TRUE)
PATTERN
Result: 2

PENCOLOR (PC)

Reports the pen color.

Syntax

PENCOLOR

Description

PENCOLOR reports the current pen color of the first active turtle as a four-element list of red, green and blue color values, plus the alpha value. Use SETPC to alter the drawing color for all active turtles.

Example

SETPC "RED
FD 50
PC
Result: [255 0 0 1]

SETALPHA

Sets the default alpha value for colors.

Syntax

SETALPHA alphavalue

Description

Color names and color indexes do not have an own alpha value. If you use a color name or index together with a turtle command like e.g. SETPC, Logo looks up the color and returns that color with the alpha value set to the turtle's alpha value. The same happens if you supply a list of three color values without an alpha value.

Example

ALPHA
Result: 1
SETPC "RED
PC
Result: [255 0 0 1]
SETALPHA 0.5
SETPC "RED
PC
Result: [255 0 0 0.5]
; set an even more transparent pen color
SETPC [255 0 0 0.3]
PC
Result: [255 0 0 0.3]

SETBG

Sets the background color.

Syntax

SETBG color-index
SETBG "color-name
SETBG [red green blue alpha]

Description

SETBG takes a color name (which is one of 138 standard Web color names, see COLORS), or a list of up to four values, one each for Red, Green, and Blue, plus an optional alpha value. The color values may vary from 0 to 255, and the alpha value is between 0 and 1.

SETBG sets the background color of the Graphics canvas, leaving the current drawing untouched. If a background pattern is set, any background image is visible through the background pattern.

For an explanation of how background patterns and images play together, see LOADPIC.

For a complete list of color names, see COLORS.

Example

MAKE "MY.BG BG
SETBG "GOLD
SETBG :MY.BG

SETBGPATTERN

Sets the background pattern.

Syntax

SETBGPATTERN number
SETBGPATTERN list
SETBGPATTERN bitmap-name

Description

SETBGPATTERN takes a number, a list or a bitmap name as input and sets a pattern for the background of the graphics canvas. The BGPATTERN command reports the currently selected background pattern. To see a list of predefined patterns, see SETPATTERN. Pattern 0 is an all-on pattern. If you set that pattern, SETBG sets solid colors, hiding any background image.

Note that you can use the name of a turtle to set the background pattern to a turtle image, but since the turtle have numbers as names, use numbers above 11, because the values 0 to 11 set standard patterns.

For an explanation of how background patterns and images play together, see LOADPIC.

If SETBGPATTERN is called with a list of eight numbers between 0 and 255, this list is treated as an 8×8 bit pattern to be used as the background pattern. If SETBGPATTERN is called with the name of a bitmap or turtle object, the image of that object is used as a pattern. Note that you cannot use the numbers 0 to 11 to refers to turtles, as these values set a predefined pattern.

SETPATTERN

Sets the turtle pattern.

Syntax

SETPATTERN number
SETPATTERN list
SETPATTERN turtle

Description

SETPATTERN takes a number or list as input and sets a pattern for filling ovals (using STAMPOVAL) and rectangles (using STAMPRECT). The PATTERN command reports the number of the currently selected fill pattern. If the input value is 0, any existing pattern is removed. The predefined fill patterns are:

1 2 3 4 5 6 7 8 9 10 11

If SETPATTERN is called with a list of eight numbers between 0 and 255, this list is treated as an 8×8 bit pattern to be used as the background pattern. If SETPATTERN is called with the name of a bitmap or turtle object, the image of that object is used as a pattern. Note that you cannot use the numbers 0 to 11 to refers to turtles, as these values set a predefined pattern.

Example

SETPC "RED
SETPATTERN 2
(STAMPRECT 100 100 TRUE)
PATTERN
Result: 2

SETPC

Sets the pen color.

Syntax

SETPC color-value
SETPC "color-name
SETPC [red green blue alpha]

Description

SETPC takes a color name (which is one of 138 standard Web color names, see COLORS), or a list of up to four values, one each for Red, Green, and Blue, plus an optional alpha value. The color values may vary from 0 to 255, and the alpha value is between 0 and 1. SETPC sets the pen color for all active turtles. If the alpha value is omitted, or a color name or index is used, the turtle's alpha value is used (see SETALPHA.

To set the background color of the Graphics canvas, use SETBG.

SETTEXTCOLOR

Sets the text color in the Output panel.

Syntax

SETTEXTCOLOR foreground background
(SETTEXTCOLOR foreground)

Description

SETTEXTCOLOR sets the foreground and background colors that subsequent print commands will be using. SETTEXTCOLOR takes a color name (which is one of 138 standard Web color names, see COLORS), or a list of up to four values, one each for Red, Green, and Blue, plus an optional alpha value. The color values may vary from 0 to 255, and the alpha value is between 0 and 1.

Example

SETTEXTCOLOR "RED
PR [THIS IS IN RED]
SETTEXTCOLOR "BLACK