Advertisement
MariaSolovieva

Untitled

May 17th, 2022
568
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. mport turtle
  2.  
  3. screen = turtle.Screen()
  4. screen.setup(1000,1000)
  5. screen.setworldcoordinates(-1000,-1000,1000,1000)
  6. screen.tracer(0,0)
  7. turtle.speed(0)
  8. turtle.hideturtle()
  9. turtle.color('red')
  10.  
  11. def cross():
  12.     turtle.right(45)
  13.     turtle.forward(70)
  14.     turtle.backward(140)
  15.     turtle.forward(70)
  16.     turtle.left(90)
  17.     turtle.forward(70)
  18.     turtle.backward(140)
  19.     turtle.forward(70)
  20.  
  21.  
  22. def draw_cross(x,y,length):
  23.     turtle.up()
  24.     turtle.goto(x-length/2,y-length/6)
  25.     turtle.down()
  26.     for _ in range(4):
  27.         turtle.forward(length)
  28.         turtle.right(90)
  29.  
  30.  
  31. def vicsek(x,y,length,n):
  32.     if n==0:
  33.         draw_cross(x,y,length)
  34.         return
  35.  
  36.     vicsek(x,y,length/3,n-1)
  37.     vicsek(x+length/3,y,length/3,n-1)
  38.     vicsek(x-length/3,y,length/3,n-1)
  39.     vicsek(x,y+length/3,length/3,n-1)
  40.     vicsek(x,y-length/3,length/3,n-1)
  41.  
  42.  
  43. cross()
  44. for x in range(100, 600, 200):
  45.     vicsek(x,0,100,5)
  46.     turtle.color('white')
  47.     cross()
  48.     turtle.goto(x+100, 0)
  49.     turtle.color('red')
  50.     cross()
  51.  
  52. screen.update()
  53.  
  54. turtle.hideturtle()
  55. turtle.exitonclick()
  56.  
Advertisement
RAW Paste Data Copied
Advertisement