Home > Software design >  How to overlap shapes using turtle: pentagon and star?
How to overlap shapes using turtle: pentagon and star?

Time:06-13

I am trying to overlap the two shapes I have below. Any advice?

import turtle

turtleStar = turtle.Turtle()

for s in range(5):

turtleStar.forward(100)
turtleStar.right(144)

for p in range(5):

turtleStar.forward(85)
turtleStar.right(72)

CodePudding user response:

import turtle

turtleStar = turtle.Turtle()

for s in range(5):
    turtleStar.forward(100)
    turtleStar.right(144)

turtleStar.left(36)
turtleStar.forward(62)

for p in range(4):
    turtleStar.right(72)
    turtleStar.forward(62)

CodePudding user response:

Try this: I just moved the start position of the second turtle

from turtle import Turtle

turtleStar = Turtle()

for s in range(5):
    turtleStar.forward(112)
    turtleStar.right(144)

turtleStar.hideturtle()
turtleStar = Turtle()
turtleStar.pu()
turtleStar.goto(turtleStar.xcor()   13,turtleStar.ycor()   40)
turtleStar.pd()

for p in range(5):
    turtleStar.forward(86)
    turtleStar.right(72)

turtleStar.screen.mainloop()
  • Related