示例#1
0
 def make_canvas(self, state, coords):
     canvas = Canvas()
     characters = self.characters(state)
     put_characters_on_canvas(canvas, characters,
                              state.coords_for(coords, characters),
                              self.options.text_color.color)
     return canvas
示例#2
0
async def tile_dice(target, serials, afr, **kwargs):
    canvas = Canvas()

    def default_color_func(i, j):
        if j == -3:
            return Color(0, 1, 0.4, 3500)
        return Color(0, 0, 0, 3500)

    canvas.set_default_color_func(default_color_func)

    numbers = ["1", "2", "3", "4", "5"]
    characters = [dice[n] for n in numbers]
    color = Color(100, 1, 1, 3500)
    put_characters_on_canvas(canvas, characters, coords_for_horizontal_line, color)

    orientations = {}
    async for pkt, _, _ in target.script(TileMessages.GetDeviceChain()).run_with(
        serials, afr, **kwargs
    ):
        if pkt | TileMessages.StateDeviceChain:
            orientations[pkt.serial] = orientations_from(pkt)

    made, _ = make_rgb_and_color_pixels(canvas, 5)

    msgs = []
    for serial in serials:
        os = orientations.get(serial)
        for msg in canvas_to_msgs(
            canvas, coords_for_horizontal_line, duration=1, acks=True, orientations=os
        ):
            msg.target = serial
            msgs.append(msg)

    await target.script(msgs).run_with_all(None, afr, **kwargs)
    return made
示例#3
0
 def make_canvas(self, state, coords):
     canvas = Canvas()
     characters = self.characters(state)
     coords = state.coords_for(coords, characters,
                               getattr(self.options, "large_font", False))
     put_characters_on_canvas(canvas, characters, coords,
                              self.options.text_color.color)
     return canvas
示例#4
0
    def make_canvas(self, state, coords):
        chars = state["chars"]

        if state["chars"] == -1:
            self.every = 0.5
            chars = [full_character] * 5

        if state["chars"] == -2:
            self.duration = 0.5
            self.every = 1.5
            chars = [random.choice(list(dice.values()))] * 5

        canvas = Canvas()
        put_characters_on_canvas(canvas, chars, coords, self.options.dice_color.color)
        return canvas
示例#5
0
    def make_canvas(self, state, coords):
        canvas = Canvas()

        line_length = (8 * 5) * (state.second / 60)
        (user_x, user_y), (width, height) = coords[0]
        if not self.options.full_height_progress:
            user_y = user_y - height + 1
            height = 1

        def get_color(x, y):
            if x < line_length:
                return self.options.progress_bar_color.color

        canvas.set_all_points_for_tile(user_x, user_y, width * 5, height, get_color)

        time_characters = [alphabet_8[ch] for ch in list(state.time_string)]
        put_characters_on_canvas(canvas, time_characters, coords, self.options.number_color.color)
        return canvas
示例#6
0
 def make_canvas(self, state, coords):
     canvas = Canvas()
     put_characters_on_canvas(canvas, state.characters,
                              state.coords_for(coords))
     return canvas