source: rgbkbd/trunk/rgbkbd/modes/basicmodes.py @ 71

Last change on this file since 71 was 71, checked in by retracile, 9 years ago

Initial import of source code

  • Property svn:executable set to *
File size: 1.3 KB
Line 
1#!/usr/bin/python
2from rgbkbd.core import Monochrome, KeyboardMode
3from rgbkbd.color import Color, Colors
4from rgbkbd.animation import RandomAnimation, ColorAnimation
5
6# Keyboard Modes
7def StaticMode(manager, keyboard, foreground=Colors.WHITE,
8        background=Colors.BLACK):
9    return KeyboardMode(manager, keyboard,
10        static_lighting=Monochrome(keyboard, color=foreground),
11        animations=[])
12
13
14def RandomMode(manager, keyboard, foreground=None, background=None):
15    """Keyboard mode for RandomAnimation"""
16    if foreground is None:
17        foreground = Color.random8(exclude=background)
18    if background is None:
19        background = Color.random8(exclude=foreground)
20
21    return KeyboardMode(manager, keyboard,
22        static_lighting=Monochrome(keyboard, color=background),
23        animations=[
24            RandomAnimation(foreground=foreground, background=background, keyboard=keyboard),
25        ])
26
27
28def ColorMode(manager, keyboard, colors=(Colors.WHITE, Colors.BLACK),
29        period=5, color_pattern_cls=None):
30    """Keyboard mode to apply a stationary color pattern"""
31    color_pattern = color_pattern_cls(colors=colors, period=period)
32    animation = ColorAnimation(keyboard=keyboard, color_pattern=color_pattern)
33    return KeyboardMode(manager, keyboard,
34        static_lighting=Monochrome(keyboard, color=colors[-1]),
35        animations=[animation])
Note: See TracBrowser for help on using the repository browser.