Terrapin Resources

Terrapin Logo 4 has been discontinued! Our new Terrapin Logo version is much more powerful and modern; we strongly recommend that you update to our latest release of the Logo programming language.

Colors

These commands assign colors to the background of the Graphics window, 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 three values, one each for Red, Green, and Blue. These three values may vary from 0 to 255.

For a list of color names and their indexes or color values, see the Logo Colors page.

BACKGROUND

Also: BG

Reports the background color.

Syntax

Description

BACKGROUND reports a list of RGB values that represents the current background color of the Graphics window.

Example

MAKE “MY.BG BG SETBG “LIME SETBG :MY.BG

COLORINDEX

Also: BASECOLOR

Coerces a color value to a basic Logo color number.

Syntax

Description

COLORINDEX takes a color name (which is one of 138 standard Web color names, see COLORS), or a list of three values, one each for Red, Green, and Blue. These three values may vary from 0 to 255. 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

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. If SETBGPATTERN was called with a user defined pattern (a list of eight numbers between 0 and 255), BGPATTERN reports this list, and if SETBGPATTERN was called with the name of a bitmap object, BGPATTERN reports this name. BGPATTERN reports 0 if no pattern is set.

COLOR

Reports the color for a name or value if possible.

Syntax

Description

COLOR takes 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 three values, one each for Red, Green, and Blue. These three values may vary from 0 to 255. COLOR attempts to match the input to a table of known color names. If a match is found, COLOR outputs the corresponding three-element list of color values. 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 three-element list of color values from 0 to 255, COLOR reports that list.

See also COLORNAME and COLORS.

Example

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

COLORNAME

Reports the name of a color if possible.

Syntax

Description

COLORNAME takes a number between 0 and 137 for the 138 Web colors or a list of three values, one each for Red, Green, and Blue. These three values may vary from 0 to 255. COLORNAME attempts to match its input to a known color name. 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

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.

Note: Color indexes have changed from Terrapin Logo 3 to Terrapin Logo 4. The index values 16 to 137 now address the additional standard Web colors in alphabetical order. See the Logo Colors page for more information.

Example

COUNT COLORS Result: 138

PATTERN

Reports the turtle’s pattern.

Syntax

Description

PATTERN reports a number that represents the current fill pattern of the first active turtle. To set the fill pattern of all active turtles, use SETPATTERN. To see a list of predefined fill patterns, see SETPATTERN. If SETPATTERN is called with a user defined pattern (a list of eight numbers between 0 and 255), PATTERN reports this list, and if SETPATTERN is called with the name of a turtle, PATTERN reports this name. PATTERN reports 0 if no pattern is set.

Example

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

PENCOLOR

Also: PC

Reports the pen color.

Syntax

Description

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

Example

SETPC “RED FD 50 PC Result: [255 0 0]

SETBG

Sets the background color.

Syntax

Description

SETBG takes 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 three values, one each for Red, Green, and Blue. These three values may vary from 0 to 255. SETBG sets the background color of the Graphics window. SETBG fills the drawing area from the outside of the Graphics window toward the center. Any drawings surrounded by a closed line, like circles, or rectangles, are not be filled when the background color is changed.

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

Description

SETBGPATTERN takes a number or list as input and sets a pattern for the background of the graphics screen. The command erases all graphics contents. The BGPATTERN command reports the currently selected background pattern. To see a list of predefined patterns, see SETPATTERN. The value 0 erases any pattern. Note that turtle numbers cannot be used to set the pattern to a turtle’s shape.

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.

SETPATTERN

Sets the turtle pattern.

Syntax

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:

                       
0   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 for fill operations. If SETPATTERN is called with the name of a turtle, the shape of that turtle is used as a pattern.

Example

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

SETPC

Sets the pen color.

Syntax

Description

SETPC takes 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 three values, one each for Red, Green, and Blue. These three values may vary from 0 to 255. SETPC sets the pen color for all active turtles. To set the background color of the Graphics window, use SETBG.