コード例 #1
0
class FlipTile(Tile):
    '''
    Abstract widget class for one Tile. We also have the ability
    to completely invert whatever the concrete subclass chooses
    to do.
    '''

    def __init__(self, interval=10, limit=10):
        Tile.__init__(self, interval, limit)
        b = Block(8, 8).fill(LampState.FLIP)

        self.__masterFrame = Frame()
        self.__masterFrame.add(self.getFrame(), 0, 0).add(b, 0, 0).hide(b)
        self.__flipped = False
        self.__flipper = b

    def recyclable(self): return True

    def getMasterFrame(self):
        'Return the master frame for display'
        return self.__masterFrame

    def prepare(self):
        if self.__flipped:
            self.__masterFrame.hide(self.__flipper)
        else:
            self.__masterFrame.show(self.__flipper)

        self.__flipped = not self.__flipped
コード例 #2
0
 def __compose(self, f1, f2):
     '''
     This isn't totally right as a case analysis - the nudging
     property is subtle - but it'll do as a demo.
     '''
     if f1 is None and f2 is None:
         return None
     else:
         frame = Frame()
         if not f1 is None: frame.add(f1, 0, 0)
         if not f2 is None: frame.add(f2, 8, 0)
         return frame
コード例 #3
0
ファイル: Tiles.py プロジェクト: cassiel/net.loadbang.shado
            draw()

        return True


block = MyBlock()
frame = Frame()
manager = PressManager(frame)

# We can no longer add a block to a frame more than once (we don't use stamps
# any more) so we have to add a ViewPort to each instance.

for x in range(0, 8, 2):
    for y in range(0, 8, 2):
        frame.add(ViewPort(block, 0, 0, 2, 2), x, y)


def bang():
    pass


def press(x, y, how):
    manager.press(x, y, how)


def draw():
    renderer.render(frame)


draw()
コード例 #4
0
ファイル: Simple.py プロジェクト: cassiel/net.loadbang.shado
'''
A simple toggle of a 4 x 4 block of LEDs. Push any
button to show the block.
'''

from net.loadbang.shado import Frame, Block
from net.loadbang.shado.types import LampState
from config import renderer

block = Block(4, 4).fill(LampState.ON)

frame = Frame()
frame.add(block, 2, 2)
blank = Frame()


def bang():
    '''ignore metronome input.'''
    pass


def press(x, y, n):
    if n == 1:
        test()
    else:
        clear()


def test():
    renderer.render(frame)
コード例 #5
0
ファイル: Simple.py プロジェクト: cassiel/net.loadbang.shado
'''
A simple toggle of a 4 x 4 block of LEDs. Push any
button to show the block.
'''

from net.loadbang.shado import Frame, Block
from net.loadbang.shado.types import LampState
from config import renderer

block = Block(4, 4).fill(LampState.ON)

frame = Frame()
frame.add(block, 2, 2)
blank = Frame()

def bang():
    '''ignore metronome input.'''
    pass

def press(x, y, n):
    if n == 1:
        test()
    else:
        clear()

def test():
    renderer.render(frame)

def clear():
    renderer.render(blank)
コード例 #6
0
            draw()

        return True


block = MyBlock()
frame = Frame()
manager = PressManager(frame)

# We can no longer add a block to a frame more than once (we don't use stamps
# any more) so we have to add a ViewPort to each instance.

for x in range(0, 8, 2):
    for y in range(0, 8, 2):
        frame.add(ViewPort(block, 0, 0, 2, 2), x, y)


def bang():
    pass


def press(x, y, how):
    manager.press(x, y, how)


def draw():
    renderer.render(frame)


draw()
コード例 #7
0
    def __init__(self, name):
        self.__name = name

        # General tools:
        self.__random = Random()

        # Full frame, which can hold two tiles next to each other (X or Y):
        ffr = Frame()

        # Window frame, original matching the monome, within which we move
        # the full frame

        wfr = Frame()

        # Cropped renderable, which is the one we actually render (so that we
        # don't overwrite any adjacent pixels in a bigger design).

        port = ViewPort(wfr, 0, 0, 8, 8)

        # Create a pool of tiles - we can populate __tilePool to hard-wire the
        # first tile if we want to test it explicitly.
        # Cursor() is a special-case, manually loaded for the first few bars.

        self.__fixedTiles = {
            'CURSOR' : Cursor(),
            'BANG' : Bang()
        }

        self.__tilePool = []

        self.__usedPool = [
            Moonbase(),
            Hanoi(False),
            Hanoi(True),
            Eclipse(),
            Spell(),
            Shards(1),
            Shards(3),
            Bars(),
            Border(),
            Flash4(4),
            Flash4(2),
            Cross(),
            Counter(),
            PixelFlip(),
            FourWay()
        ]

        # Set up the first tile:
        t = self.__chooseTile()

        # Set up out state: the stamp for our starting tile.
        ffr.add(t.getMasterFrame(), 0, 0)
        self.__this = TileState(t)
        self.__next00 = None

        # Locate the full frame at (0, 0) within the Monome.
        wfr.add(ffr, 0, 0)

        # We'll need these later:
        self.__fullFrame = ffr
        self.__windFrame = wfr
        self.__viewPort = port

        # Not used (yet), but let's be clean:
        self.__vector = (0, 0)

        self.__nudging = False
コード例 #8
0
            else:
                self.fill(LampState.OFF)

            draw()

        return True


frame = Frame()
manager = PressManager(frame)

# 8 x 16 just for our personal testing:

for x in range(16):
    for y in range(8):
        frame.add(MyBlock(), x, y)


def bang():
    pass


def press(x, y, how):
    manager.press(x, y, how)


def draw():
    renderer.render(frame)


draw()
コード例 #9
0
from net.loadbang.shado import Frame, Block
from net.loadbang.shado.types import LampState
from config import renderer

digits = [
    '111 101 101 101 111', '110 010 010 010 010', '111 001 111 100 111',
    '111 001 111 001 111', '101 101 111 001 001', '111 100 111 001 111',
    '111 100 111 101 111', '111 001 001 001 001', '111 101 111 101 111',
    '111 101 111 001 111'
]

frame = Frame()
renderer.render(frame)

mainframe = Frame()
f = mainframe.add(frame, 0, 0)

lftBlocks = [Block(digits[i]) for i in range(10)]
rhtBlocks = [Block(digits[i]) for i in range(10)]

for i in range(10):
    frame.add(lftBlocks[i], 0, 0).add(rhtBlocks[i], 5, 0)

counter = 99
interval = 0


def bang():
    global interval
    global counter
コード例 #10
0
ファイル: Buttons.py プロジェクト: cassiel/net.loadbang.shado
    def press(self, x, y, how):
        if how != 0:
            if self.getLamp(0, 0) == LampState.OFF:
                self.fill(LampState.ON)
            else:
                self.fill(LampState.OFF)

            draw()

        return True

frame = Frame()
manager = PressManager(frame)

# 8 x 16 just for our personal testing:

for x in range(16):
    for y in range(8):
        frame.add(MyBlock(), x, y)

def bang():
    pass

def press(x, y, how):
    manager.press(x, y, how)

def draw():
    renderer.render(frame)

draw()
コード例 #11
0
ファイル: Counter.py プロジェクト: cassiel/net.loadbang.shado
    '110 010 010 010 010',
    '111 001 111 100 111',
    '111 001 111 001 111',
    '101 101 111 001 001',
    '111 100 111 001 111',
    '111 100 111 101 111',
    '111 001 001 001 001',
    '111 101 111 101 111',
    '111 101 111 001 111'
]

frame = Frame()
renderer.render(frame)

mainframe = Frame()
f = mainframe.add(frame, 0, 0)

lftBlocks = [Block(digits[i]) for i in range(10)]
rhtBlocks = [Block(digits[i]) for i in range(10)]

for i in range(10):
    frame.add(lftBlocks[i], 0, 0).add(rhtBlocks[i], 5, 0)

counter = 99
interval = 0

def bang():
    global interval
    global counter

    interval += 1
コード例 #12
0
'''

from net.loadbang.shado import Frame, Block, ViewPort
from net.loadbang.shado.types import LampState
from config import renderer

block = Block(4, 4).fill(LampState.THRU)

# We can no longer add a block to a frame more than once (we don't use stamps
# any more) so we have to add a sub-frame to each instance.

frame = Frame()

position = 0

frame.add(Frame().add(block, 0, 0), 0, 0)
frame.add(Frame().add(block, 0, 0), 4, 0)
frame.add(Frame().add(block, 0, 0), 0, 4)
frame.add(Frame().add(block, 0, 0), 4, 4)
frame.add(Frame().add(block, 0, 0), 2, 2)

count = 0


def bang():
    global count
    count += 1
    if count % 10 == 0: doit()


def press(x, y, n):
コード例 #13
0
ファイル: Animate.py プロジェクト: cassiel/net.loadbang.shado
'''

from net.loadbang.shado import Frame, Block, ViewPort
from net.loadbang.shado.types import LampState
from config import renderer

block = Block(4, 4).fill(LampState.THRU)

# We can no longer add a block to a frame more than once (we don't use stamps
# any more) so we have to add a sub-frame to each instance.

frame = Frame()

position = 0

frame.add(Frame().add(block, 0, 0), 0, 0)
frame.add(Frame().add(block, 0, 0), 4, 0)
frame.add(Frame().add(block, 0, 0), 0, 4)
frame.add(Frame().add(block, 0, 0), 4, 4)
frame.add(Frame().add(block, 0, 0), 2, 2)

count = 0

def bang():
    global count
    count += 1
    if count % 10 == 0: doit()

def press(x, y, n): pass

def doit():