Add Hackertours room and animation #4

Merged
stb merged 9 commits from hackertours into main 2024-12-17 12:15:13 +01:00
Showing only changes of commit 10b89e784f - Show all commits

View file

@ -238,7 +238,7 @@ class Hackertours(Steady):
""" """
Base color yellow, with green wandering back and forth Base color yellow, with green wandering back and forth
""" """
def __init__(self, color, base=(255,255,0), looptime=2.0): def __init__(self, color, base=(255,255,0), looptime=4.0):
super(Hackertours, self).__init__(color) super(Hackertours, self).__init__(color)
self.looptime = looptime self.looptime = looptime
self.base = base self.base = base
@ -246,8 +246,6 @@ class Hackertours(Steady):
def update(self, index, count): def update(self, index, count):
# angle is the position of the highlight on a circle, range [0, 1] # angle is the position of the highlight on a circle, range [0, 1]
angle = (time() / self.looptime + (index + 0.0) / count) % 1.0 angle = (time() / self.looptime + (index + 0.0) / count) % 1.0
# map 0->1, 0.5->0, 1->1 to convert from circle to cylon
angle = abs(angle * 2 - 1)
l = 1 - min(abs(angle - 1 / count) * .9, 1.0 / count) * count l = 1 - min(abs(angle - 1 / count) * .9, 1.0 / count) * count
return ( return (
int(self.r * l + self.base[0] * (1-l)), int(self.r * l + self.base[0] * (1-l)),