Specifying a Pen
pendown()
Lowers the pen, enabling drawing.
Syntax: pendown() (no argument)
• When you move the turtle with the pen down, a line is drawn from the current location of the turtle to its
destination. To move the turtle, use the functions under
(page 132)
and
"Moving to Specified Coordinates" (page
penup()
Raises the pen, disabling drawing.
Syntax: penup() (no argument)
• When the pen is up, nothing is drawn if the turtle is moved.
pencolor()
• Specifies the line drawing color or returns the value of the line drawing color.
Syntax 1: pencolor(colorstring)
• colorstring argument: Uses a keyword to specify the line drawing color.
- Type: str
- How to specify: Use the syntax pencolor("keyword") to specify the color. The text strings below can be
specified as keywords
black, blue, green, red, cyan, yellow, magenta, white, orange, purple, brown, pink, grey
Syntax 2: pencolor(list)
• list argument: Uses RGB values to specify the line drawing color.
- Type: list or tuple
- Element type: int or float
- How to specify: Use the syntax [r,g,b] (0 ≤ r ≤ 1, 0 ≤ g ≤ 1, 0 ≤ b ≤ 1) to specify RGB values. Each RGB
value corresponds to a Syntax 1 keyword as shown in the table below.
Keyword
RGB Values
black
blue
green
red
cyan
Syntax 3: pencolor() (no argument)
• Returns the RGB values (or the keyword if applicable) of the current line drawing color.
pensize(), width()
Specifies the line width or returns the value of the current line width.
Syntax 1: pensize(n)
width(n)
• n argument: Specifies the line width as a real number from 0 to 5. The greater the number, the wider the
line.
- Type: int or float
Syntax 2: pensize() (no argument)
Keyword
[0,0,0]
yellow
[0,0,1]
magenta
[0,1,0]
white
[1,0,0]
orange
[0,1,1]
purple
"Specifying Direction and Forward/Back Movement"
132).
RGB Values
[1,1,0]
[1,0,1]
[1,1,1]
[1,0.65,0]
[0.66,0,0.66]
131
Keyword
RGB Values
brown
[0.75,0.25,0.25]
pink
[1,0.75,0.8]
grey
[0.66,0.66,0.66]
Need help?
Do you have a question about the CLASSWIZ CG and is the answer not in the manual?
Questions and answers