HomeTurtlegraficsGPanelRobotics WebTigerPython
 Python - Online
farben
Deutsch   English   

2. USE COLORS

 

 

YOU LEARN HERE...

 

some more Turtle commands. You can use them to draw beautiful colored pictures. On the website trinket.io/docs/colors you will find 140 colors that you can use in your Turtle graphics programs. You can see the color name in English by clicking on the desired color with the mouse. The following list shows some color names: yellow, gold, orange, red, maroon, violet, magenta, purple, navy, blue, skyblue, cyan, turquoise, lime, green, darkgreen, chocolate, brown, black, gray, white.

 

 

EXAMPLE

 

You want to draw a burning red candle with the Turtle. First you draw the candle itself with a thick red pen. Then move a little further with the pen lifted and draw a yellow-filled circle with the dot(40)command. To draw the wick, move back slightly with a thin black pen.

As new functions you need setPenColor() for the pen color setPenWidth() ffor the pen thickness, penUp() and penDown() to lift the pen up and down. Finally, hide the turtle with hideTurtle().

 

Programm:    

from gturtle import *

setPenWidth(60)
setPenColor("red")
forward(100) 
penUp()
forward(50)
penDown()
setPenColor("yellow")
dot(40)
setPenWidth(5)
setPenColor("black")
back(15) 
hideTurtle()
► Copy to clipboard

 

 

REMEMBER...

 

Use setPenColor(“color”) to change the pen color. Use setColor(“color”) to change the turtle color. On the website trinket.io/docs/colorsyou will find many other colors that you can use as pen and turtle colors. The color names are not case-sensitive, but they must be enclosed in quotation marks.

The # character is used in Python for comments. You can use it to insert comments that are not taken into account when the program is executed.

 

 

TO SOLVE BY YOURSELF

 

1.

Complete the program below so that the Turtle draws a regular hexagon and choose a different color for each side.
from gturtle import *
makeTurtle()
setPenWidth(5)
setPenColor("red")
forward(80)
right(60)
 
2.

Draw filled circles with the colors “red”, “yellow”, “blue” and “magenta”. Continue drawing circles with colors that you can find at r trinket.io/docs/colors.



 

3.

Draw a traffic light. You can draw the black rectangle with a pen width of 80.