Example #1
0
        op2, np2 = old_percentage*2, new_percentage*2
        if delta > 0:  # moving division to right (filling up)
            self._colors['color'][op2:np2] = self.fill_color
            slc = slice(op2, np2, None)
        else:  # moving division to left (filling down)
            self._colors['color'][np2:op2 + 1] = self.empty_color
            slc = slice(np2, op2+1, None)
        self._delta_view = self._colors[slc].view(np.ubyte)
        self._offset = slc.start * 16
        self._percentage = new_percentage


if __name__ == '__main__':
    from mglg.graphics.shaders import VertexColorShader
    from gonogo.visuals.window import ExpWindow as Win
    from time import sleep

    win = Win()
    per_vert = VertexColorShader(win.context)
    fill_bar = FillBar(win.context, per_vert, fill_color=[0.3, 0.8, 0.2, 1],
                       empty_color=[0.2, 0.2, 0.2, 1], scale=1, rotation=90)
    for i in range(100):
        fill_bar.percentage -= 1
        fill_bar.draw(win.cam)
        win.flip()
    for i in range(100):
        fill_bar.percentage += 1
        fill_bar.draw(win.cam)
        win.flip()
    sleep(0.4)
Example #2
0
    from gonogo.scenes import *
    from gonogo.utils import camel_to_snake, snake_to_camel, rush
    from gonogo.scenes.done import Done
    from gonogo import __version__

    from toon.input import MpDevice, mono_clock
    from gonogo.devices.custom import Custom
    from gonogo.devices.keyboard import Keyboard
    import pip._vendor.pytoml as toml

    # first, we'll get a window + context up ASAP
    # this takes a certain amount of time (~750-1000ms)
    freeze_support()  # TODO: can this just live somewhere in toon?
    can_rush = rush(True)  # test if rush will have an effect
    rush(False)
    win = Window()

    # instantiate the device
    hids = any([e['vendor_id'] == 0x16c0 for e in hid.enumerate()])
    ports = list_ports.comports()
    serials = next((p.device for p in ports if p.pid == 1155),
                   None)  # M$ calls it a microsoft device
    if not hids and serials is None:
        warn('Special device not attached, falling back to keyboard.')
        device = MpDevice(Keyboard(keys=['k', 'l'], clock=mono_clock.get_time))
        device_type = 'keyboard'
    else:
        device = MpDevice(Custom(clock=mono_clock.get_time))
        device_type = 'custom'

    # next, we'll pull up the IMGUI dialog window to get