polecenie | Szczegóły parametru | przykład | ||||||||||
turtle.forward(distance)
turtle.fd(distance) |
distance – a number (integer or float) | turtle.forward(25) | ||||||||||
turtle.back(distance)
turtle.bk(distance) turtle.backward(distance) |
turtle.backward(30) | |||||||||||
turtle.right(angle)
turtle.rt(angle) |
angle – a number (integer or float) | turtle.right(45 | ||||||||||
turtle.left(angle)
turtle.lt(angle) |
turtle.left(45) | |||||||||||
turtle.goto(x, y)
turtle.setpos(x, y) turtle.setposition(x, y) |
turtle.goto(60,30) | |||||||||||
turtle.setheading(to_angle)
turtle.seth(to_angle) |
to_angle – a number (integer or float)
Set the orientation of the turtle to to_angle. Here are some common directions in degrees:
|
turtle.setheading(90) | ||||||||||
turtle.home() | Move turtle to the origin – coordinates (0,0) | turtle.home() | ||||||||||
turtle.circle(radius, extent, steps) | radius – a number
extent – a number (or None) steps – an integer (or None)
|
turtle.circle(50)
turtle.circle(120, 180) # draw a semicircle |
||||||||||
turtle.dot(size=None, *color) | size – an integer >= 1 (if given)
color – a colorstring or a numeric color tuple
|
turtle.dot(20, „blue”) | ||||||||||
turtle.speed(speed) | speed – an integer in the range 0..10 or a speedstring (see below)
· “fastest”: 0 · “fast”: 10 · “normal”: 6 · “slow”: 3 · “slowest”: 1 Attention: speed = 0 means that no animation takes place. forward/back makes turtle jump and likewise left/right make the turtle turn instantly. |
turtle.speed(’normal’)
turtle.speed(9) |
||||||||||
turtle.pendown()
turtle.pd() turtle.down() |
Pull the pen down – drawing when moving. | |||||||||||
turtle.penup()
turtle.pu() turtle.up() |
Pull the pen up – no drawing when moving. | |||||||||||
turtle.pensize(width)
turtle.width(width) |
width – a positive number | turtle.pensize(10) | ||||||||||
turtle.pencolor()
turtle.pencolor(colorstring) turtle.pencolor(r, g, b) |
turtle.pencolor(„brown”)
turtle.pencolor(51.0, 204.0, 140.0) turtle.pencolor(’#32c18f’) |
|||||||||||
turtle.fillcolor()
turtle.fillcolor(colorstring) turtle.fillcolor(r, g, b) |
turtle. fillcolor(„brown”)
turtle. fillcolor(51.0, 204.0, 140.0) turtle. fillcolor(’#32c18f’) |
|||||||||||
turtle.reset() | Delete the turtle’s drawings from the screen, re-center the turtle and set variables to the default values. | turtle.reset() | ||||||||||
turtle.clear() | Delete the turtle’s drawings from the screen. Do not move turtle. State and position of the turtle as well as drawings of other turtles are not affected. | turtle.clear() | ||||||||||
turtle.hideturtle()
turtle.ht() |
Make the turtle invisible. It’s a good idea to do this while you’re in the middle of doing some complex drawing, because hiding the turtle speeds up the drawing observably. | turtle.hideturtle()
turtle.ht() |
||||||||||
turtle.showturtle()
turtle.st() |
Make the turtle visible. | turtle.showturtle()
turtle.st() |
||||||||||
turtle.shape(name) | name – a string which is a valid shapename
Initially there are the following polygon shapes: “arrow”, “turtle”, “circle”, “square”, “triangle”, “classic”. |
turtle.shape(„turtle”) |