Skip to content

Instantly share code, notes, and snippets.

@rootVIII
Last active May 30, 2022 16:20
Show Gist options
  • Save rootVIII/e183b4e15fb7af94a68a203d44cb758a to your computer and use it in GitHub Desktop.
Save rootVIII/e183b4e15fb7af94a68a203d44cb758a to your computer and use it in GitHub Desktop.
Python recursively draw a sine wave with Python
#! /usr/bin/python3
# rootVIII
# Make turtle recursively
# draw a sine wave
from turtle import *
import time
import math
def draw_sine(x):
if not x < 50:
print("done")
else:
y = 30 * math.sin(.5 * x)
setx(x)
sety(y)
penup()
goto(x, y)
dot()
pendown()
draw_sine(x + .25)
if __name__ == "__main__":
x = -50
penup()
draw_sine(x)
time.sleep(100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment