You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
839 B
37 lines
839 B
4 years ago
|
# SPDX-FileCopyrightText: 2018 Coinkite, Inc. <coldcardwallet.com>
|
||
|
# SPDX-License-Identifier: GPL-3.0-only
|
||
|
#
|
||
|
#!/usr/bin/env python3
|
||
|
from math import sin, pi
|
||
|
from collections import Counter
|
||
|
|
||
|
W = 128 # screen width
|
||
|
PW = 12 # width of eye
|
||
|
parts = 53 # of animation steps
|
||
|
|
||
|
dr = (2*pi) / parts
|
||
|
RW = W - PW - 1
|
||
|
|
||
|
ampl = (RW/2) + .5
|
||
|
offset = (W/2) - (PW/2)
|
||
|
|
||
|
rv = []
|
||
|
r = 0
|
||
|
for n in range(parts):
|
||
|
x = (ampl * sin(r)) + offset
|
||
|
x = int(x+.5)
|
||
|
print(f'{n:2d}: {x:3d} ' + (' '*x) + 'X')
|
||
|
r += dr
|
||
|
rv.append(x)
|
||
|
|
||
|
assert rv[0]+(PW//2) == W//2, rv[0]
|
||
|
assert max(rv) == W-PW, max(rv)
|
||
|
assert min(rv) == 0, min(rv)
|
||
|
|
||
|
# only want it to hesitate at the ends
|
||
|
cnt = Counter(rv).most_common()
|
||
|
assert max(c for x,c in cnt) == 2, repr(cnt)
|
||
|
|
||
|
print("\nResult: " + ', '.join(str(i) for i in rv))
|
||
|
print("\ncylon = %r" % bytes(rv))
|