Reference › Pen and Color — 71 commands


backgroundcolor

Also: screencolor bg

pen and color

Input: none
Output: number

Returns the current background color.

print backgroundcolor
0

backgroundshade

Also: bgs

pen and color

Input: none
Output: shade (number)

Returns the current background shade value. See setbackgroundshade

show backgroundshade

color

pen and color

Input: number
Output: list

color returns the red, green and blue values of the specified color

show color 5
[128 128 128]
show color brown
[128 80 0]

colors

pen and color

Input: none
Output: list

Returns a list of lists containing all of the colors' RGB values in order of color index, eg with the first list being [0 0 0] (black) and the 16th list being white [255 255 255]. For an easier-to-read version, see listcolors

show colors

definecolor

Also: dfw

pen and color

Input: index (number) | list or word
Output: none

definecolor takes an index number from 0 to 63 and either a list of three values (representing red, green, and blue) with a value from 0 to 100, or a 6-character word representing a color's RGB values in hexadecimal format, for example ab1274. The color palette defined by definecolor is used for pen and fill colors. To use definecolor to alter the colors used in a turtle model, definecolor must be used inside the turtle model definition. For text colors see definetextcolor

definecolor 20 [50 20 90]
definecolor 21 "ab1274

definecolors

pen and color

Input: list of lists
Output: none

Defines all 64 color palettes based on the provided list of 64 RGB (0-100) values.

definecolors colors

fillcolor

Also: fc

pen and color

Input: none
Output: number

Returns the fill color currently used by the selected turtle.

print myrtle:fillcolor
7

fillshade

Also: fsh

pen and color

Input: none
Output: shade (number)

Returns the current fillshade value. See setfillshade

show fillshade

fillopacity

pen and color

Input: none
Output: opacity (number)

Returns the current fill opacity

show opacity

gradient

pen and color

Input: none
Output: none

Causes lines, squares, quads, spots, polyspots, spheres, toruses, voxels, cylinders, cylinderarcs, tubes, funnels, cones and pyramids to graduate in color from the pencolor value to the fillcolor value. nogradient disables it. See gradientp

cs gradient randpc randfc repeat 36 [fd 100 rt 170]

lightlines

pen and color

Input: none
Output: none

Enables lighting for lines. Normally off by default. As lines have no 'side', their 'normal' (the direction in which light is reflected) needs to be manually set using setlinesnormal. nolightlines disables it.

lightlines

listcolors

pen and color

Input: none
Output: none

Prints out the 64 (0-63) color indexes and their associated RGB values. See colors, showcolors

listcolors

nogradient

pen and color

Input: none
Output: none

Disables gradient. See gradient

nogradient

nolightlines

pen and color

Input: none
Output: none

Disables line lighting. See lightlines

nolightlines

nopencaps

pen and color

Input: none
Output: none

Disables pencaps, which add 'caps' to the start and end of lines. See pencaps, pencapsp

setpenwidth 10 nopencaps forward 50

nopenjoins

pen and color

Input: none
Output: none

Disables penjoins, which create an intermediary shape that connects two consecutive line segments. See penjoins

nopenjoins

pen

pen and color

Input: none
Output: word

Returns the pen state, PENUP or PENDOWN

show pen
PENUP

pencaps

pen and color

Input: none
Output: none

Causes starting and ending 'caps' to be added to lines. See nopencaps, pencapsp

setpenwidth 10 pencaps forward 50

pencolor

Also: pc

pen and color

Input: none
Output: number

Returns the current pen color.

show pencolor

pendepth

pen and color

Input: none
Output: word

Returns the current pen depth. Currently only applicable to the 'mark' penstyle. See setpenstyle

show pendepth

pendown

Also: pd

pen and color

Input: none
Output: none

Puts the calling turtle's 'pen' down (causes it to draw a line when moved).

repeat 10 [pendown forward 10 penup forward 10]

penjoins

pen and color

Input: none
Output: none

When enabled, causes an intermediate 'join' to be created between two line segments in pen styles that support it (currently pipe and mark) nopenjoins disables it. See setpenstyle, penjoinsp

setpenstyle "mark setpenwidth 6 penjoins
repeat 4 [forward 50 right 90]

penopacity

pen and color

Input: none
Output: number

Returns the calling turtles pen opacity. See setpenopacity

shoe penopacity

penshade

Also: psh

pen and color

Input: none
Output: shade (number)

Returns the current pen shade value. See setpenshade

show penshade

pensides

pen and color

Input: none
Output: number

Returns the number of sides of the cylinder drawn by the pen primitives when penwidth > 1. See setpensides

show pensides

penstyle

pen and color

Input: none
Output: word

Returns the current pen style.

show penstyle

penstyles

pen and color

Input: none
Output: word

Returns the available pen styles.

show penstyles

penup

Also: pu

pen and color

Input: none
Output: none

Lifts the calling turtle's pen up, it won't draw a line when it moves. See pendown

repeat 10 [pendown forward 10 penup forward 10]

penwidth

Also: pw

pen and color

Input: none
Output: number OR list

Returns the current pen width. See setpenwidth

show penwidth

randombackgroundcolor

Also: randbg rbg

pen and color

Input: none
Output: none

Selects a random background color (0 - 15). See setbackgroundcolor

repeat 50 [randbg] setbg 0

randombackgroundshade

Also: randbs rbs

pen and color

Input: none
Output: none

Selects a random background shade (-12 to 12). See setbackgroundshade

repeat 5 [randbs wait 30]

randomfillcolor

Also: randfc rfc

pen and color

Input: none
Output: none

Sets a random fill color (1 - 15) that is NOT the current fill color. See setfillcolor

randomfillcolor sphere 10

randomfillopacity

Also: randfo

pen and color

Input: none
Output: none

Sets a random fill opacity. See setfillopacity

repeat 5 [randomfillopacity voxel 20 forward 25]

randomfillshade

Also: randfs rfs

pen and color

Input: none
Output: none

Sets a random fill shade value between -12 and 12. See setfillshade

setfillcolor 5
repeat 6 [randomfillshade sphere 10 10 10 penup forward 25]

randompencolor

Also: randpc rpc

pen and color

Input: none
Output: none

Sets a random pen color (1 - 15) that is NOT the current pen color. See setpencolor

pendown repeat 10 [randvec randompencolor fd 100 home]

randompenopacity

Also: randpo

pen and color

Input: none
Output: none

Sets a random pen opacity. See setpenopacity

setpenwidth 6
repeat 10 [randompenopacity forward 20 right 36]

randompenshade

Also: randps rps

pen and color

Input: none
Output: none

Sets a random pen shade value between -12 and 12. See setpenshade

setpenwidth 4
repeat 12 [randompenshade forward 30 back 30 right 30]

randompenwidth

Also: randpw

pen and color

Input: none
Output: none

Sets a random pen width value

repeat 8 [randompenwidth forward 40 back 40 right 45]

setbackgroundcolor

Also: setbg sbg

pen and color

Input: number
Output: none

Sets the background color to the color index referenced by the provided number. Note that you can use the color names referenced in the colors primitive description, because they are actually functions which return the corresponding index number.

setbackgroundcolor 5
setbg yellow

setfillcolor

Also: setfc sfc

pen and color

Input: color (number)
Output: none

Sets the 'fill' color used by the turtle when creating shapes.

setfillcolor 3
setfillcolor blue

setfillshade

Also: setfs sfs

pen and color

Input: shade (number)
Output: none

Sets the shade of the fill color to be displayed when rendering subsequent shapes. It can be set to a number from 0 to 15, which represents a decrease in brightness of the fill color of 6.25 times that number. So, a value of 8 decreases the brightness by 50%. Negative shade values add 1/16th of the difference between each of the base RGB values of the color and 255

setfillshade 5

setfillopacity

Also: setfo

pen and color

Input: opacity (number)
Output: none

Sets the fill opacity, takes a number from 0 to 100.

setfillopacity 50

setlinesnormal

pen and color

Input: vector (list)
Output: none

Sets the 'normal' vector to be used by lightlines. All lines use the same vector. This is easiest taken from a turtle. Remember that if you take the forwarddir from Snappy, you will need to reverse it, using vectorsub! See lightlines

setlinesnormal vectorsub snappy:forwarddir [0 0 0]

setpencolor

Also: setpc spc

pen and color

Input: color (number)
Output: none

Sets the pen color to the provided color index. Note that there are a number of color functions that return their corresponding numbers, such as yellow and blue, that can be used in place of a number. See colors

setpencolor yellow
setpc 13

setpendepth

Also: setpd

pen and color

Input: number
Output: none

Sets the depth of the pen, used currently only by the mark and voxel styles. pendepth is automatically set to the value of penwidth when the voxel penstyle is selected, but can be changed afterwards. See setpenstyle, pendepth

setpendepth 5

setpenshade

Also: setps sps

pen and color

Input: shade (number)
Output: none

Sets the shade of the pen color to be displayed when rendering subsequent lines. It can be set to a number from 0 to 15, which represents a decrease in brightness of the pen color of 6.25 times that number. So, a value of 8 decreases the brightness by 50%.

setpenshade 5

setpenopacity

Also: setpo spo

pen and color

Input: number
Output: none

Sets the pen's opacity. Takes a number from 0 to 100.

setpenopacity 50

setpensides

pen and color

Input: sides (number)
Output: none

Sets the number of sides of the cylinder created by the pen primitives when the penwidth is > 1. The default is 10. See pensides

setpensides 3

setpenstyle

Also: setpst

pen and color

Input: style (word)
Output: none

Sets the pen 'style' – there are currently 4 styles: line, mark, tube and voxel. line is a thin opengl line, mark is a flat ribbon, tube is a cylinder and voxel is a series of world-aligned voxels (like Minecraft). If the penwidth is changed to a number greater than one, the line penstyle automatically changes to mark or tube, depending on if the current Space is 2D or 3D. See penstyle, pendepth and setpendepth (the last two apply only to the mark and voxel styles)

setpenstyle "mark

setpenwidth

Also: spw setpw

pen and color

Input: number OR [startwidth endwidth]
Output: none

Sets the width of the pen. If the penwidth is set higher than 1, cylinders are drawn instead of lines (as OpenGL has deprecated other line widths). You can also supply a list of two widths, the first being the starting width of the line, and the second being the ending width of the line. See setpensides to set the number of sides larger penwidths have. Note that because multiple pen sizes may now be used in the same creation, clearscreen resets the penwidth. See also mark (for wider, two-dimensional lines)

setpenwidth 5
setpenwidth [5 10]

snip

pen and color

Input: none
Output: none

Removes the second-last point (the point before the turtle's current position) and then connects the third-last and current, creating a line between them. Used to smooth out designs that use orbit, for example.

fd 20 rt 90 fd 20 snip

black

pen and color

Input: none
Output: number

Returns the color number for black (0).

setpencolor black

blue

pen and color

Input: none
Output: number

Returns the color number for blue (2).

setpencolor blue

brown

pen and color

Input: none
Output: number

Returns the color number for brown (8).

setpencolor brown

cyan

pen and color

Input: none
Output: number

Returns the color number for cyan (14).

setpencolor cyan

gray

pen and color

Input: none
Output: number

Returns the color number for gray (5). Also available as grey.

setpencolor gray

green

pen and color

Input: none
Output: number

Returns the color number for green (4).

setpencolor green

grey

pen and color

Input: none
Output: number

Returns the color number for grey (5). Same as gray.

setpencolor grey

lightblue

pen and color

Input: none
Output: number

Returns the color number for light blue (7).

setpencolor lightblue

lightgray

pen and color

Input: none
Output: number

Returns the color number for light gray (10). Also available as lightgrey.

setpencolor lightgray

lightgreen

pen and color

Input: none
Output: number

Returns the color number for light green (12).

setpencolor lightgreen

lightgrey

pen and color

Input: none
Output: number

Returns the color number for light grey (10). Same as lightgray.

setpencolor lightgrey

magenta

pen and color

Input: none
Output: number

Returns the color number for magenta (3).

setpencolor magenta

~markerwidth

pen and color

Input: none
Output: number

Returns the current marker width setting.

print ~markerwidth

mediumblue

pen and color

Input: none
Output: number

Returns the color number for medium blue (6).

setpencolor mediumblue

orange

pen and color

Input: none
Output: number

Returns the color number for orange (9).

setpencolor orange

pc

pen and color

Input: none
Output: number | list

Short form of pencolor. Returns the current pen color.

print pc

pink

pen and color

Input: none
Output: number

Returns the color number for pink (11).

setpencolor pink

red

pen and color

Input: none
Output: number

Returns the color number for red (1).

setpencolor red

white

pen and color

Input: none
Output: number

Returns the color number for white (15).

setpencolor white

yellow

pen and color

Input: none
Output: number

Returns the color number for yellow (13).

setpencolor yellow