Advertisement
here2share

# t_wave_overlays.py

Feb 12th, 2021
1,039
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. # t_wave_overlays.py
  2.  
  3. import wave
  4. import math
  5. from turtle import Turtle, Screen
  6. from itertools import cycle
  7.  
  8. COLORS = cycle(['red', 'blue', 'green', 'purple', 'yellow'])
  9.  
  10. def draw_wave():
  11.     turtle.penup()
  12.     turtle.color(next(COLORS))
  13.     for x in range(20,100):
  14.         y_val = amp * math.sin(math.radians(x * freq))
  15.         turtle.goto(x-10, y_val)
  16.         turtle.pendown()
  17.  
  18. screen = Screen()
  19. screen.bgcolor('lightyellow')
  20. screen.setworldcoordinates(0, -400, 100, 400)
  21. screen.setup(600, 600)
  22.  
  23. turtle = Turtle('turtle')
  24. turtle.hideturtle()
  25. turtle.speed('fastest')
  26. turtle.width(2)
  27.        
  28. amp = 360
  29. while 1:
  30.     freq_list = []
  31.     for freq in range(1,200):
  32.         freq_list.append(freq)
  33.         print(('\nAmp = '+str(amp)+' '*16)[:16]+'Freq = '+str(freq))
  34.         draw_wave()
  35.     amp -= 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement