summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-03-31 00:39:15 +0200
committerMattias Andrée <maandree@operamail.com>2014-03-31 00:39:15 +0200
commit87bd5286b95f0fd3c1feae56f1634578a8a06d6f (patch)
tree165bd1f45f5f7f3778553bfd0f00f1cc50036da1
parentm + document (diff)
downloadblueshift-87bd5286b95f0fd3c1feae56f1634578a8a06d6f.tar.gz
blueshift-87bd5286b95f0fd3c1feae56f1634578a8a06d6f.tar.bz2
blueshift-87bd5286b95f0fd3c1feae56f1634578a8a06d6f.tar.xz
m doc + do not override fadein_time or fadeout_time with None if fadein_steps or fadeout_steps, respectively, is non-positive
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rwxr-xr-xsrc/__main__.py29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/__main__.py b/src/__main__.py
index a3ba573..62829b6 100755
--- a/src/__main__.py
+++ b/src/__main__.py
@@ -410,9 +410,14 @@ def continuous_run():
signal_(signal.SIGALRM, signal_SIGALRM)
## Create initial transition
+ # Fade in
trans_delta = -1
+ # from clean state.
trans_alpha = 1
+ with_fadein = lambda : (fadein_steps > 0) and (fadein_time is not None)
+ with_fadeout = lambda : (fadeout_steps > 0) and (fadeout_time is not None)
+
while running:
if trans_delta == 0:
## Run periodically
@@ -421,26 +426,22 @@ def continuous_run():
sleep(wait_period)
elif trans_delta < 0:
## Fade in
- if fadein_steps <= 0:
- fadein_time = None
- if not ((fadein_time is None) or panicgate):
+ if with_fadein() and not panicgate:
if trans_alpha == 0:
p(now(), 1 - trans_alpha)
sleep(fadein_time / fadein_steps)
trans_alpha -= 1 / fadein_steps
- if (trans_alpha <= 0) or (fadein_time is None) or panicgate:
+ if not (with_fadein() and not panicgate):
trans_alpha = 0
trans_delta = 0
p(now(), 1 - trans_alpha)
- if fadein_time is not None:
+ if with_fadein():
sleep(fadein_time / fadein_steps)
else:
## Fade out
- if fadeout_steps <= 0:
- fadeout_time = None
- if not (fadeout_time is None):
+ if with_fadeout():
trans_alpha += 1 / fadeout_steps
- if (trans_alpha >= 1) or (fadeout_time is None):
+ if (trans_alpha >= 1) or not with_fadeout():
trans_alpha = 1
p(now(), -1 + trans_alpha)
if trans_alpha == 1:
@@ -450,19 +451,19 @@ def continuous_run():
except KeyboardInterrupt:
signal_SIGTERM(0, None)
else:
- if fadeout_time is not None:
+ if with_fadeout():
sleep(fadeout_time / fadeout_steps)
## Fade out
- if fadeout_steps <= 0:
- fadeout_time = None
- if not (fadeout_time is None):
+ if with_fadeout():
while not panic:
trans_alpha += 1 / fadeout_steps
- if (trans_alpha >= 1) or (fadeout_time is None):
+ if trans_alpha >= 1:
trans_alpha = 1
panic = True
p(now(), -1 + trans_alpha)
+ if not with_fadeout():
+ break
sleep(fadeout_time / fadeout_steps)
## Reset