We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a7b59f8 commit f5fa438Copy full SHA for f5fa438
src/flitter/language/functions/waves.pyx
@@ -87,14 +87,12 @@ def square(Vector xs not None):
87
return ys
88
89
90
-def triangle(Vector xs not None):
91
- if xs.numbers == NULL:
+def triangle(Vector xs):
+ if xs is None or xs.numbers == NULL:
92
return null_
93
cdef Vector ys = Vector.__new__(Vector)
94
- cdef double x, y
+ cdef double x
95
for i in range(ys.allocate_numbers(xs.length)):
96
x = xs.numbers[i]
97
- x -= floor(x)
98
- y = 1 - abs(x - 0.5) * 2
99
- ys.numbers[i] = y
+ ys.numbers[i] = 1 - abs((x - floor(x))*2 - 1)
100
0 commit comments