示例#1
0
    def render(self, strike):
        if self.solved:
            return self.get_image('#0f0'), 'render.png'

        led = '#f00' if strike else '#fff'

        if self.cycle is None:
            return self.get_image('#f00' if strike else '#fff'), 'render.png'

        with Image() as im:
            for column in self.cycle:
                first = True
                for _ in range(6):
                    modules.gif_append(im, self.get_image(led),
                                       200 if first else 100)
                    first = False
                    self.positions[column] = (self.positions[column] + 1) % 6

            return modules.gif_output(im)
示例#2
0
    def render(self, strike):
        if self.solved:
            return SimonSays.get_image(None, '#0f0'), 'render.png'

        led = '#f00' if strike else '#fff'

        with Image() as im:

            def add(color, delay):
                modules.gif_append(im, SimonSays.get_image(color, led), delay)

            add(None, 200)

            first = True
            for color in self.sequence[:self.progress + 1]:
                if not first:
                    add(None, 10)

                add(color, 60)
                first = False

            return modules.gif_output(im)
示例#3
0
    def render(self, strike):
        if self.solved:
            return self.get_image(False, '#0f0'), 'render.png'

        led = '#f00' if strike else '#fff'

        on = self.get_image(True, led)
        off = self.get_image(False, led)

        with Image() as im:

            def add(frame, units):
                modules.gif_append(im, frame, units * DOT_LENGTH)

            for letter in self.word:
                add(off, 3)
                first_signal = True
                for signal in modules.utils.LETTER_TO_MORSE[letter]:
                    if not first_signal: add(off, 1)
                    first_signal = False
                    add(on, 3 if signal == '-' else 1)
            add(off, 4)

            return modules.gif_output(im)