Command List

StarLogo has 14 "major" colors, with many shades of each. Different shades are associated with different numbers. For example, the shades of red are associated with the numbers between 10 and 20 (not including 20). Number 10 is a very "dark" red (close to black), number 15 is the "purest" red, and number 19 is a "light" red (close to white). Similarly, number 20 is a dark orange, number 25 is the purest orange, and number 29 is a light orange. (Note: Fractional numbers can also represent different shades, if your computer supports enough colors.)

These numbers are used as inputs to the commands setc (which sets the color of turtles) and setpc (which sets the color of patches). So the command ask-patches[setpc 15] will turn all of the patches red, while ask-patches[setpc 19] will turn the patches a much lighter shade of red. Type ask-patches[setpc xcor + ycor] to see the full range of colors. Color numbers greater than 140 "wrap" (using modulo 140).

The organization of colors by shades is very useful for achieving smooth shading effects using the commands scale-color and scale-pc.

There are commands (e.g., black, red, green) that report color values. These commands report the number for the "purest" shade of the color. For example, red reports 15 and orange reports 25. Color names report numbers in the color listing:

black 0 gray, grey 5
white 9 red 15
orange 25 brown 35
yellow 45 green 55
lime 65 turquoise 75
cyan 85 sky 95
blue 105 violet, purple 115
magenta 125 pink 135

Turtle, Observer, Patch

black

Description:
Reports 0, the number of its particular hue in the color table.

Related Commands:
blue brown cyan gray green lime magenta orange pink purple red sky turquoise white yellow
Turtle, Observer, Patch

blue

Description:
Reports 105, the number of its particular hue in the color table.

Related Commands:
black blue brown cyan gray green lime magenta orange pink purple red sky turquoise white yellow
Turtle, Observer, Patch

brown

Description:
Reports 35, the number of its particular hue in the color table.

Related Commands:
black blue cyan gray green lime magenta orange pink purple red sky turquoise white yellow
Turtle, Patch

color

Description:
Returns the color of the turtle, or if a patch is calling it, the color of one of the turtles on the patch.

Examples:
if color = black
[fd 3]

has all turtles check if they are black, and if so, move themselves forward by 3 turtle steps.

Related Commands:
color-at color-of color-towards setcolor who
Turtle, Observer, Patch

color-at xcor ycor

Parameters:
xcor Number units in the x direction away from the caller
ycor Number units in the y direction away from the caller

Description:
Reports the color of the turtle xcor units in the x direction and ycor units in the y direction away from the caller .

Examples:
color-at 1 1 reports the color of the turtle one unit to the right and one unit above the patch or turtle given the command.

Related Commands:
color color-of color-towards setc-at
Turtle, Observer, Patch

color-of number

Parameters:
number Number who-number

Description:
Reports the color of the turtle with who number number.

Examples:
color-of 2 returns the color number of the turtle with who-number 2

Related Commands:
color color-at color-towards setc-of
Turtle, Observer, Patch

color-towards angle distance

Parameters:
angle Number angle from the caller
distance Number distance away from the caller

Description:
Reports the color of the turtle distance away at an angle of angle from the caller. Note that the angle is measured from the direction the caller is facing.

Examples:
color-towards 0 1 reports the color of the turtle one patch directly ahead of the caller.

Related Commands:
color color-at color-of setc-towards
Turtle, Observer, Patch

count-color color

Parameters:
color Number color of turtles to be counted

Description:
Returns the number of turtles that are the color color.

Examples:
count-color black returns the number of black turtles.

Related Commands:
count-color-range count-pc count-pc-range
Turtle, Observer, Patch

count-color-range mincolor maxcolor

Parameters:
mincolor Number low end of range of color of turtles to be counted
maxcolor Number high end of range of color of turtles to be counted

Description:
Returns the number of turtles that have colors between mincolor and maxcolor, inclusive.

Examples:
count-color-range 13.5 16.5 returns the number of turtles who are red (15) or within 1.5 shades of red. This command is useful if you have scaled your turtle's colors to shades of a particular color using scale-color.

Related Commands:
count-color count-pc count-pc-range
Turtle, Observer, Patch

count-pc color

Parameters:
color Number color to determine whether to count a patch

Description:
Returns the number of patches that are the color color.

Examples:
count-pc blue returns the number of blue patches.

Notes:
This command can also be executed by patches, for example within an ask-patches statement.

Related Commands:
count-color count-color-range count-pc-range
Turtle, Observer, Patch

count-pc-range mincolor maxcolor

Parameters:
mincolor Number low end of range of colors to determine whether to count a patch
maxcolor Number high end of range of colors to determine whether to count a patch

Description:
Returns the number of patches that have colors between mincolor and maxcolor, inclusive.

Examples:
count-pc-range 64 66.5 returns the number of patches that are lime (65) or very close to it.

Related Commands:
count-color count-color-range count-pc
Turtle, Observer, Patch

cyan

Description:

cyan reports 85, the number of its particular hue in the color table.

Related Commands:
black blue brown gray green lime magenta orange pink purple red sky turquoise white yellow
Turtle, Observer, Patch

gray (grey)

Description:
gray reports 5, the number of its particular hue in the color table.

Related Commands:
black blue brown cyan green lime magenta orange pink purple red sky turquoise white yellow
Turtle, Observer, Patch

green

Description:
green reports 55, the number of its particular hue in the color table.

Related Commands:
black blue brown cyan gray green lime magenta orange pink purple red sky turquoise white yellow
Turtle, Observer, Patch

lime

Description:
lime reports 65, the number of its particular hue in the color table.

Related Commands:
black blue brown cyan gray green magenta orange pink purple red sky turquoise white yellow
Turtle, Observer, Patch

magenta

Description:
magenta reports 125, the number of its particular hue in the color table.

Related Commands:
black blue brown cyan gray green lime orange pink purple red sky turquoise white yellow
Turtle, Observer, Patch

orange

Description:
Reports 25, the number of its particular hue in the color table.

Related Commands:
black blue brown cyan gray green lime magenta pink purple red sky turquoise white yellow
Turtle, Patch

patchcolor (pc)

Description:
Reports the color of the patch the turtle is on.

Examples:
if pc = red [fd 1] commands the turtle to move forward one unit if the color of the patch the turtle is on is red.

Notes:
This command can also be executed by patches, for example within an ask-patches statement.

Related Commands:
pc-ahead pc-ahead-one-patch pc-at pc-towards setbg setpc stamp
Turtle

pc-ahead (pc-ahead-one-step)

Description:
Reports the color of the patch one space ahead in the direction that the turtle is facing. If called by the observer, it will assume coordinates of (0,0).

Notes:
if pc-ahead = blue [fd 1] commands the caller to move forward 1 if the patch ahead of it is blue.

Related Commands:
patchcolor pc-ahead-one-patch pc-at pc-towards
Turtle, Observer, Patch

pc-at xcor ycor

Parameters:
xcor Number
ycor Number

Description:
Reports the color of the patch xcor units in the x direction and ycor units in the y direction away from the caller.

Examples:
pc-at 1 1 reports the color of the patch one unit to the right and one unit above the caller.

Notes:
This command can also be executed by patches, for example within an ask-patches statement.

Related Commands:
patchcolor pc-ahead pc-towards stamp-at
Turtle, Observer, Patch

pc-towards angle distance

Parameters:
angle Number
distance Number

Description:
Reports the color of the patch angle away at an angle distance from the caller.

Examples:
pc-towards 0 1 returns the color of the patch which is one unit directly in front of the caller.

Notes:
This command can also be executed by patches, for example within an ask-patches statement.

Related Commands:
patchcolor pc-ahead pc-at stamp-towards
Turtle, Observer, Patch

pink

Description:
pink reports 135, the number of its particular hue in the color table.

Related Commands:
black blue brown cyan gray green lime magenta orange purple red sky turquoise white yellow
Turtle, Observer, Patch

ppc

Description:
Returns the current plot pen color.

Related Commands:
pp ppd ppreset ppu ppxcor ppycor setppc
Patch

pstamp color

Parameters:
color Color

Description:
Allows patches to set the color of the turtle that is on it to color.

Examples:
pstamp blue sets the color of the turtles on top of the called patch to blue.

Related Commands:
pstamp-at pstamp-towards stamp
Patch

pstamp-at xcor ycor color

Parameters:
xcor Number
ycor Number
color Color

Description:
Allows patches to set the color of the turtle xcor patches in the x-direction and ycor patches in the y-direction away to color.

Examples:
pstamp-at 1 1 blue commands the patch to set the color of the turtles one unit to the right and one unit above the called patch to the color blue.

Related Commands:
pstamp pstamp-towards stamp-at
Patch

pstamp-towards angle distance color

Parameters:
angle Number
distance Number
color Color

Description:
Allows patches to set the color of the turtle distance units away at an angle of angle to color.

Examples:
pstamp-towards 0 1 blue sets the color of the turtles one unit directly ahead of the called patch to the color blue.

Related Commands:
pstamp pstamp-at stamp-towards
Turtle, Observer, Patch

purple

Description:
violet reports 115, the number of its particular hue in the color table.

Related Commands:
black blue brown cyan gray green lime magenta orange pink red sky turquoise white yellow
Turtle, Observer, Patch

red

Description:
red reports 15, the number of its particular hue in the color table.

Related Commands:
black blue brown cyan gray green lime magenta orange pink purple sky turquoise white yellow
Turtle, Patch

scale-color color variable limit1 limit2

Parameters:
color Number Color
variable Number Variable color
limit1 Number Lower limit
limit2 Number Upper limit

Description:
Turtles set their color to a shade of color based on their value of variable. limit1 and limit2 determine the amount of gradation. If a patch calls this, all turtles on that patch scale their color.

Examples:
scale-color blue energy 0 20 Turtles turn one of twenty shades of blue. Turtles with lower energy turn darker blue.

scale-color blue energy 20 0
Turtles turn one of twenty shades of blue. Turtles with lower energy turn lighter blue.

Notes:
If the turtle exceeds the limits, it turns black on the dark end of the specturm and turns white on the bright end of the spectrum.

Related Commands:
scale-pc
Turtle, Patch

scale-pc color variable limit1 limit2

Parameters:
color Number Color
variable Number
limit1 Number Lower limit
limit2 Number Upper limit

Description:
Patches set their color to a shade of color based on their value of variable. limit1 and limit2 determine the amount of gradation. If a turtle calls this, the patch underneath the turtle scale its patch color.

Examples:
scale-color green density 0 20
Patches turn one of twenty shades of green. Patches with lower density turn darker green.

scale-color blue energy 20 0
Patches turn one of twenty shades of green. Patches with lower density turn lighter green.

Notes:
This is a patch command. It must be called from within an ask-patches or ask-patch-at statement.

If the patch exceeds the limits, it turns black on the dark end of the specturm and turns white on the bright end of the spectrum.

Related Commands:
scale-color setpc
Observer

setbg color

Parameters:
color Color

Description:
Sets the color of all the patches to color.

Examples:
setbg blue sets the color of all the patches to blue.

Related Commands:
ask-patches patchcolor setpc
Turtle, Observer, Patch

setc-at xcor ycor color

Parameters:
xcor Number
ycor Number
color Color

Description:
Sets the color of the turtle at (xcor, ycor) to color.

Examples:
setc-at 1 1 0 sets the color of the turtle at (1,1) to black.

Related Commands:
color-at setc-of setc-towards setcolor
Turtle, Observer, Patch

setc-of turtleid color

Parameters:
turtleid Number who number of the turtle whose color should be changed
color Color

Description:
Sets the color of the turtle with ID turtleid$ to color color.

Examples:
setc-of 2 0 sets the color of the turtle with who number 2 to black.

Related Commands:
color-of setc-at setc-towards setcolor
Turtle, Observer, Patch

setc-towards angle distance color

Parameters:
angle Number
distance Number
color Color

Description:
Sets the color of the turtle angle away at angle distance from the caller to color.

Examples:
setc-towards 0 1 0 sets the color of the turtle one unit directly in front of the caller to black.

Related Commands:
color-towards setc-at setc-of setcolor
Turtle

setcolor (setc) colorname

Parameters:
colorname Color

Description:
Turtles set their color to colorname.

Examples:
setc brown

setc 45

Related Commands:
color setc-at setc-of setc-towards
Patch

setpc (setpatchcolor) color

Parameters:
color Color

Description:
This command is run as a patch command inside an ask-patches statement. The patches being asked will set their color to color. Use stamp if you want to have a turtle change the color of a patch.

Examples:
ask-patches [setpc blue] commands the patches to set their color to blue.

Related Commands:
patchcolor scale-pc setbg stamp
Turtle, Observer, Patch

setppc color

Parameters:
color Color

Description:
Sets the color of the current plot pen to be color.

Examples:
setppc black sets the current plot pen to black.

Related Commands:
pp ppc
Turtle, Observer, Patch

sky

Description:
sky reports 95, the number of its particular hue in the color table.

Related Commands:
black blue brown cyan gray green lime magenta orange pink purple red turquoise white yellow
Turtle, Observer, Patch

turquoise

Description:
turquoise reports 75, the number of its particular hue in the color table.

Related Commands:
black blue brown cyan gray green lime magenta orange pink purple red sky white yellow
Turtle, Observer, Patch

white

Description:
white reports 9, the number of its particular hue in the color table.

Related Commands:
black blue brown cyan gray green lime magenta orange pink purple red sky turquoise yellow
Turtle, Observer, Patch

yellow

Description:
yellow reports 45, the number of its particular hue in the color table.

Related Commands:
black blue brown cyan gray green lime magenta orange pink purple red sky turquoise white