简体   繁体   中英

What is the easiest method to draw this on the screen using turtle graphics?

在此处输入图片说明

What would be the easiest method to draw this on the screen including colors?

It's kind of hard to answer this question without code, but if you know what the colored turtles are called, you can use:

[turtle name goes here].forward([distance])

to move that given turtle forward

[turtle name goes here].backward([distance])

to move it backward

[turtle name goes here].right([degrees/radians])
[turtle name goes here].left([degrees/ radians])

to turn the turtle right and left

for example:

#names the turtle Angie
Angie = Turtle()
#changes the color of Angie
Angie.color("blue")
#moves angie forward
Angie.forward(100)

This should work, hope this helps! :-)

def polygon(length, sides, color):
    turtle.color(color)
    turtle.begin_fill()
    for i in range(sides):
        turtle.forward(length)
        turtle.left(360.0/sides)
    turtle.end_fill()
    turtle.penup()
    turtle.forward(length*1.5)
    turtle.pendown()

polygon(100, 6, "green")
polygon(100, 3, "blue")
polygon(100, 4, "red")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM