Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Studio
  4. How do I draw a recursive Sierpiński arrowhead curve using turtle graphics in python on Visual Studio Code?

How do I draw a recursive Sierpiński arrowhead curve using turtle graphics in python on Visual Studio Code?

Scheduled Pinned Locked Moved Visual Studio
questioncsharppythonvisual-studiographics
2 Posts 2 Posters 5 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Member_14743979
    wrote on last edited by
    #1

    Hi I am trying to draw a recursive Sierpiński arrowhead curve using turtle graphics in python on Visual Studio Code. I can get the basic shape just fine but I can't seem to make it rotate correctly to form the sierpinski triangle. Here's my code:

    from turtle import *
    def arrowhead(level, length):
    if level == 1:
    rt(-60)
    fd(length)
    rt(60)
    fd(length)
    rt(60) #Basic shape for level 1
    else:
    arrowhead(level-1, length/2)
    rt(60)
    for i in range(3):
    arrowhead(level-1, length/2)
    lt(-60)
    for i in range(3):
    arrowhead(level-1, length/2)
    rt(-60)
    arrowhead(level-1, length/2)
    lt(60)
    arrowhead(level-1, length/2)

    arrowhead(4, 400)

    L 1 Reply Last reply
    0
    • M Member_14743979

      Hi I am trying to draw a recursive Sierpiński arrowhead curve using turtle graphics in python on Visual Studio Code. I can get the basic shape just fine but I can't seem to make it rotate correctly to form the sierpinski triangle. Here's my code:

      from turtle import *
      def arrowhead(level, length):
      if level == 1:
      rt(-60)
      fd(length)
      rt(60)
      fd(length)
      rt(60) #Basic shape for level 1
      else:
      arrowhead(level-1, length/2)
      rt(60)
      for i in range(3):
      arrowhead(level-1, length/2)
      lt(-60)
      for i in range(3):
      arrowhead(level-1, length/2)
      rt(-60)
      arrowhead(level-1, length/2)
      lt(60)
      arrowhead(level-1, length/2)

      arrowhead(4, 400)

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      This is the Visual Studio forum. We do not have a forum specifically for Python yet, so please use Quick Answers[^]

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups