Пример #1
0
class ExamplePlugin:
    def __init__(self):
        self.screen = Screen(matrix=False, show=True, fps=23)
        self.label = Text()
        self.drawing = Image(64, 16)
        self.drawer = Drawer(self.drawing)
        self.screen.add(self.drawing)
        self.screen.add(self.label)

    def stream(self):
        for i in range(1, 101):
            self.drawer.line(i, 0, 9, i)
            self.label.edit(str(i))
            self.screen.refresh()
            msg("Progression", 0, None, i)
Пример #2
0
class ClockPlugin:
    def __init__(self):
        self.author = 'Infected'
        self.name = 'Clock Plugin'
        self.version = 'V3.23-4.2-DOS.26__release'
        self.time = datetime.now()
        self.timer = Text()
        self.canvas = Image(64, 16)
        self.time_frame = Image(64, 16)
        self.canvas_draw = Drawer(self.canvas)
        self.invert = Image(64, 16)
        self.invert.fill()

        self.screen = Screen(matrix=True, show=False, fps=15)
        self.screen.add(self.time_frame, refresh=True)
        self.screen.add(self.timer, refresh=True, x=3, y=3)
        self.screen.add(self.canvas, refresh=False)
        self.screen.add(self.invert, mode='invert', refresh=False)

        self.gen_canvas()

    def get_info(self):
        """Get the current state and information of the plugin"""
        print(color(self.name, "red"),
              color(self.author, "green"),
              color(self.version, "magenta"),
              sep='\n')

    def gen_canvas(self):
        self.canvas_draw.line(0, 0, 63, 0)
        self.canvas_draw.line(0, 0, 0, 15)
        self.canvas_draw.line(0, 15, 63, 15)
        self.canvas_draw.line(63, 0, 63, 15)

    def refresh(self):
        self.time = datetime.now()

    def print_time(self):
        self.timer.edit('{}:{}:{}'.format(
            str(self.time.hour).zfill(2),
            str(self.time.minute).zfill(2),
            str(self.time.second).zfill(2)),
            font='fontbignum')

    def stream(self):
        self.refresh()
        self.print_time()
        self.screen.refresh()