From 51f31013dc19190065d6dfe1e5bd712008f4f75d Mon Sep 17 00:00:00 2001 From: Garvita Jain <42664351+garvita-jain@users.noreply.github.com> Date: Sat, 28 Sep 2019 23:35:12 +0530 Subject: [PATCH] Update __main__.py --- flyingsnake/__main__.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/flyingsnake/__main__.py b/flyingsnake/__main__.py index ae211be..2c388a4 100644 --- a/flyingsnake/__main__.py +++ b/flyingsnake/__main__.py @@ -116,17 +116,17 @@ def flyingsnake(input_file: str, c.echo("Drawing walls...") walls = Image.new("RGBA", (world.size.x, world.size.y)) draw = ImageDraw.Draw(walls) - for x in range(world.size.x): + with click.progressbar(world.tiles, length = world.size) as bar: + for x in range(world.size.x): for y in range(world.size.y): - tile = world.tiles[x, y] + tile = bar[x, y] if tile.wall: if draw_paint and tile.wall.paint: color = tuple(colors["Paints"][str(tile.wall.paint)]) else: color = tuple(colors["Walls"][str(tile.wall.type.value)]) draw.point((x, y), color) - if not x % 100: - c.echo(f"{x} / {world.size.x} rows done") + del draw to_merge.append(walls) @@ -134,9 +134,10 @@ def flyingsnake(input_file: str, c.echo("Drawing liquids...") liquids = Image.new("RGBA", (world.size.x, world.size.y)) draw = ImageDraw.Draw(liquids) - for x in range(world.size.x): + with click.progressbar(world.tiles, length = world.size) as bar: + for x in range(world.size.x): for y in range(world.size.y): - tile = world.tiles[x, y] + tile = bar[x, y] if tile.liquid: if tile.liquid.type == li.tiles.LiquidType.WATER: draw.point((x, y), tuple(colors["Globals"]["Water"])) @@ -144,8 +145,7 @@ def flyingsnake(input_file: str, draw.point((x, y), tuple(colors["Globals"]["Lava"])) elif tile.liquid.type == li.tiles.LiquidType.HONEY: draw.point((x, y), tuple(colors["Globals"]["Honey"])) - if not x % 100: - c.echo(f"{x} / {world.size.x} rows done") + del draw to_merge.append(liquids) @@ -153,17 +153,17 @@ def flyingsnake(input_file: str, c.echo("Drawing blocks...") blocks = Image.new("RGBA", (world.size.x, world.size.y)) draw = ImageDraw.Draw(blocks) - for x in range(world.size.x): + with click.progressbar(world.tiles, length = world.size) as bar: + for x in range(world.size.x): for y in range(world.size.y): - tile = world.tiles[x, y] + tile = bar[x, y] if tile.block: if draw_paint and tile.block.paint: color = tuple(colors["Paints"][str(tile.block.paint)]) else: color = tuple(colors["Blocks"][str(tile.block.type.value)]) draw.point((x, y), color) - if not x % 100: - c.echo(f"{x} / {world.size.x} rows done") + del draw to_merge.append(blocks) @@ -171,9 +171,10 @@ def flyingsnake(input_file: str, c.echo("Drawing wires...") wires = Image.new("RGBA", (world.size.x, world.size.y)) draw = ImageDraw.Draw(wires) - for x in range(world.size.x): + with c.progressbar(world.tiles, length = world.size) as bar: + for x in range(world.size.x): for y in range(world.size.y): - tile = world.tiles[x, y] + tile = bar[x, y] if tile.wiring: if tile.wiring.red: draw.point((x, y), tuple(colors["Globals"]["Wire"])) @@ -183,8 +184,7 @@ def flyingsnake(input_file: str, draw.point((x, y), tuple(colors["Globals"]["Wire2"])) if tile.wiring.yellow: draw.point((x, y), tuple(colors["Globals"]["Wire3"])) - if not x % 100: - c.echo(f"{x} / {world.size.x} rows done") + del draw to_merge.append(wires)