Skip to content

Commit

Permalink
test out FPS
Browse files Browse the repository at this point in the history
  • Loading branch information
tmckay1 committed May 18, 2021
1 parent cb91f45 commit 57a113e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
5 changes: 3 additions & 2 deletions animate.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@
# anim.run()

# pulse
speed = 3 # higher the number, slower it is
anim = CubePulse(layout, speed=speed)
# speed = 3 # higher the number, slower it is
fps = 24
anim = CubePulse(layout, fps=fps)
anim.run()

# laser
Expand Down
24 changes: 11 additions & 13 deletions animation/CubePulse.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,16 @@ def pre_run(self):
self._step = 0

def step(self, amt=1):
if (self._step % self._speed) == 0:
self.layout.all_off()
new_step = (self._step // self._speed)
traveling_up = (new_step // self._max_radius) % 2 == 0
radius = (new_step % self._max_radius) if traveling_up else (self._max_radius - (new_step % self._max_radius) - 1)

# this respects master brightness but is slower
for z in range(self.z):
for y in range(self.y):
for x in range(self.x):
if self._vector[x][y][z] == radius:
self.layout.set(x, y, z, self.palette(new_step % 255))
self.layout.all_off()
traveling_up = (new_step // self._max_radius) % 2 == 0
radius = (new_step % self._max_radius) if traveling_up else (self._max_radius - (new_step % self._max_radius) - 1)

# this respects master brightness but is slower
for z in range(self.z):
for y in range(self.y):
for x in range(self.x):
if self._vector[x][y][z] == radius:
self.layout.set(x, y, z, self.palette(new_step % 255))

# TODO: Handle overflow
self._step += 1
self._step += amt

0 comments on commit 57a113e

Please sign in to comment.