-
Notifications
You must be signed in to change notification settings - Fork 0
/
tangentWave.py
39 lines (28 loc) · 862 Bytes
/
tangentWave.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from math import sin, pi, tan
import ui
wire = ui.Path()
wire.line_width = 0.5
class MainView(ui.View):
def __init__(self):
self.name = 'sin -> tan'
self.bg_color = 0.2
self.update_interval = 1 / 60
self.counter = 0
self.line_stroke_color = (0.8, 0.8, 0.8, 0.8)
self.segment = 8
def draw(self):
amp = self.height / 6
for i in range(self.segment):
x = i / (self.segment - 1) * self.width
radian = (i / self.segment * pi) + (self.counter / 32)
y = (amp * tan(radian)) + (self.height / 2)
if i: wire.line_to(x, y)
else: wire.move_to(x, y)
ui.set_color(self.line_stroke_color)
wire.stroke()
def update(self):
self.counter += 1
self.set_needs_display()
if __name__ == '__main__':
main_view = MainView()
main_view.present(style='fullscreen', orientations=['portrait'])