mirror of
https://github.com/Steffo99/flyingsnake.git
synced 2024-12-21 22:24:19 +00:00
Don't draw missing colors
This commit is contained in:
parent
3b0c1233e5
commit
8e6fedacd4
6 changed files with 24 additions and 23 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -7,3 +7,5 @@ setup/
|
||||||
build/
|
build/
|
||||||
venv/
|
venv/
|
||||||
.venv/
|
.venv/
|
||||||
|
*.wld
|
||||||
|
*.png
|
||||||
|
|
|
@ -3,7 +3,6 @@ from .get_colors import get_colors_from_tedit_settings, \
|
||||||
get_wall_colors_from_tedit_settings, \
|
get_wall_colors_from_tedit_settings, \
|
||||||
get_block_colors_from_tedit_settings, \
|
get_block_colors_from_tedit_settings, \
|
||||||
get_global_colors_from_tedit_settings
|
get_global_colors_from_tedit_settings
|
||||||
from .__main__ import flyingsnake
|
|
||||||
|
|
||||||
__all__ = ["DEFAULT_COLORS", "get_colors_from_tedit_settings", "get_wall_colors_from_tedit_settings",
|
__all__ = ["DEFAULT_COLORS", "get_colors_from_tedit_settings", "get_wall_colors_from_tedit_settings",
|
||||||
"get_block_colors_from_tedit_settings", "get_global_colors_from_tedit_settings", "flyingsnake"]
|
"get_block_colors_from_tedit_settings", "get_global_colors_from_tedit_settings"]
|
||||||
|
|
|
@ -143,19 +143,19 @@ def flyingsnake(input_file: str,
|
||||||
curr_y = 0
|
curr_y = 0
|
||||||
if min_y <= world.underground_level:
|
if min_y <= world.underground_level:
|
||||||
sky_y = min(world.underground_level - min_y, height)
|
sky_y = min(world.underground_level - min_y, height)
|
||||||
draw.rectangle(((0, curr_y), (width, sky_y)), tuple(colors["Globals"].get("Sky", (255, 0, 255, 255))))
|
draw.rectangle(((0, curr_y), (width, sky_y)), tuple(colors["Globals"].get("Sky", (0, 0, 0, 0))))
|
||||||
curr_y = sky_y + 1
|
curr_y = sky_y + 1
|
||||||
if max_y > world.underground_level and min_y <= world.cavern_level:
|
if max_y > world.underground_level and min_y <= world.cavern_level:
|
||||||
earth_y = min(world.cavern_level - min_y, height)
|
earth_y = min(world.cavern_level - min_y, height)
|
||||||
draw.rectangle(((0, curr_y), (width, earth_y)), tuple(colors["Globals"].get("Earth", (255, 0, 255, 255))))
|
draw.rectangle(((0, curr_y), (width, earth_y)), tuple(colors["Globals"].get("Earth", (0, 0, 0, 0))))
|
||||||
curr_y = earth_y + 1
|
curr_y = earth_y + 1
|
||||||
edge_of_rock = world.size.y - 192
|
edge_of_rock = world.size.y - 192
|
||||||
if max_y > world.cavern_level and min_y <= edge_of_rock:
|
if max_y > world.cavern_level and min_y <= edge_of_rock:
|
||||||
rock_y = min(edge_of_rock - min_y, height)
|
rock_y = min(edge_of_rock - min_y, height)
|
||||||
draw.rectangle(((0, curr_y), (width, rock_y)), tuple(colors["Globals"].get("Rock", (255, 0, 255, 255))))
|
draw.rectangle(((0, curr_y), (width, rock_y)), tuple(colors["Globals"].get("Rock", (0, 0, 0, 0))))
|
||||||
curr_y = rock_y + 1
|
curr_y = rock_y + 1
|
||||||
if max_y > edge_of_rock:
|
if max_y > edge_of_rock:
|
||||||
draw.rectangle(((0, curr_y), (width, height)), tuple(colors["Globals"].get("Hell", (255, 0, 255, 255))))
|
draw.rectangle(((0, curr_y), (width, height)), tuple(colors["Globals"].get("Hell", (0, 0, 0, 0))))
|
||||||
del draw
|
del draw
|
||||||
to_merge.append(background)
|
to_merge.append(background)
|
||||||
|
|
||||||
|
@ -168,9 +168,9 @@ def flyingsnake(input_file: str,
|
||||||
tile = world.tiles[x, y]
|
tile = world.tiles[x, y]
|
||||||
if tile.wall:
|
if tile.wall:
|
||||||
if draw_paint and tile.wall.paint:
|
if draw_paint and tile.wall.paint:
|
||||||
color = tuple(colors["Paints"].get(str(tile.wall.paint), (255, 0, 255, 255)))
|
color = tuple(colors["Paints"].get(str(tile.wall.paint), (0, 0, 0, 0)))
|
||||||
else:
|
else:
|
||||||
color = tuple(colors["Walls"].get(str(tile.wall.type.value), (255, 0, 255, 255)))
|
color = tuple(colors["Walls"].get(str(tile.wall.type.value), (0, 0, 0, 0)))
|
||||||
draw.point((x - min_x, y - min_y), color)
|
draw.point((x - min_x, y - min_y), color)
|
||||||
if not x % 100:
|
if not x % 100:
|
||||||
c.echo(f"{x} / {width} rows done")
|
c.echo(f"{x} / {width} rows done")
|
||||||
|
@ -186,11 +186,11 @@ def flyingsnake(input_file: str,
|
||||||
tile = world.tiles[x, y]
|
tile = world.tiles[x, y]
|
||||||
if tile.liquid:
|
if tile.liquid:
|
||||||
if tile.liquid.type == le.LiquidType.WATER:
|
if tile.liquid.type == le.LiquidType.WATER:
|
||||||
color = tuple(colors["Globals"].get("Water", (255, 0, 255, 255)))
|
color = tuple(colors["Globals"].get("Water", (0, 0, 0, 0)))
|
||||||
elif tile.liquid.type == le.LiquidType.LAVA:
|
elif tile.liquid.type == le.LiquidType.LAVA:
|
||||||
color = tuple(colors["Globals"].get("Lava", (255, 0, 255, 255)))
|
color = tuple(colors["Globals"].get("Lava", (0, 0, 0, 0)))
|
||||||
elif tile.liquid.type == le.LiquidType.HONEY:
|
elif tile.liquid.type == le.LiquidType.HONEY:
|
||||||
color = tuple(colors["Globals"].get("Honey", (255, 0, 255, 255)))
|
color = tuple(colors["Globals"].get("Honey", (0, 0, 0, 0)))
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
draw.point((x - min_x, y - min_y), color)
|
draw.point((x - min_x, y - min_y), color)
|
||||||
|
@ -208,9 +208,9 @@ def flyingsnake(input_file: str,
|
||||||
tile = world.tiles[x, y]
|
tile = world.tiles[x, y]
|
||||||
if tile.block:
|
if tile.block:
|
||||||
if draw_paint and tile.block.paint:
|
if draw_paint and tile.block.paint:
|
||||||
color = tuple(colors["Paints"].get(str(tile.block.paint), (255, 0, 255, 255)))
|
color = tuple(colors["Paints"].get(str(tile.block.paint), (0, 0, 0, 0)))
|
||||||
else:
|
else:
|
||||||
color = tuple(colors["Blocks"].get(str(tile.block.type.value), (255, 0, 255, 255)))
|
color = tuple(colors["Blocks"].get(str(tile.block.type.value), (0, 0, 0, 0)))
|
||||||
draw.point((x - min_x, y - min_y), color)
|
draw.point((x - min_x, y - min_y), color)
|
||||||
if not x % 100:
|
if not x % 100:
|
||||||
c.echo(f"{x} / {width} rows done")
|
c.echo(f"{x} / {width} rows done")
|
||||||
|
@ -226,13 +226,13 @@ def flyingsnake(input_file: str,
|
||||||
tile = world.tiles[x, y]
|
tile = world.tiles[x, y]
|
||||||
if tile.wiring:
|
if tile.wiring:
|
||||||
if tile.wiring.red:
|
if tile.wiring.red:
|
||||||
color = tuple(colors["Globals"].get("Wire", (255, 0, 255, 255)))
|
color = tuple(colors["Globals"].get("Wire", (0, 0, 0, 0)))
|
||||||
elif tile.wiring.blue:
|
elif tile.wiring.blue:
|
||||||
color = tuple(colors["Globals"].get("Wire1", (255, 0, 255, 255)))
|
color = tuple(colors["Globals"].get("Wire1", (0, 0, 0, 0)))
|
||||||
elif tile.wiring.green:
|
elif tile.wiring.green:
|
||||||
color = tuple(colors["Globals"].get("Wire2", (255, 0, 255, 255)))
|
color = tuple(colors["Globals"].get("Wire2", (0, 0, 0, 0)))
|
||||||
elif tile.wiring.yellow:
|
elif tile.wiring.yellow:
|
||||||
color = tuple(colors["Globals"].get("Wire3", (255, 0, 255, 255)))
|
color = tuple(colors["Globals"].get("Wire3", (0, 0, 0, 0)))
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
draw.point((x - min_x, y - min_y), color)
|
draw.point((x - min_x, y - min_y), color)
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -11,7 +11,7 @@ def get_block_colors_from_tedit_settings(tree: ElementTree) -> typing.Dict[int,
|
||||||
|
|
||||||
for block in root:
|
for block in root:
|
||||||
id_ = block.attrib["Id"]
|
id_ = block.attrib["Id"]
|
||||||
color = block.attrib["Color"] if "color" in block.attrib else "#00000000"
|
color = block.attrib["Color"] if "Color" in block.attrib else "#00000000"
|
||||||
alpha, red, green, blue = ImageColor.getrgb(color)
|
alpha, red, green, blue = ImageColor.getrgb(color)
|
||||||
colors[id_] = red, green, blue, alpha
|
colors[id_] = red, green, blue, alpha
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ def get_wall_colors_from_tedit_settings(tree: ElementTree) -> typing.Dict[int, t
|
||||||
|
|
||||||
for wall in root:
|
for wall in root:
|
||||||
id_ = wall.attrib["Id"]
|
id_ = wall.attrib["Id"]
|
||||||
color = wall.attrib["Color"]
|
color = wall.attrib["Color"] if "Color" in wall.attrib else "#00000000"
|
||||||
alpha, red, green, blue = ImageColor.getrgb(color)
|
alpha, red, green, blue = ImageColor.getrgb(color)
|
||||||
colors[id_] = red, green, blue, alpha
|
colors[id_] = red, green, blue, alpha
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ def get_global_colors_from_tedit_settings(tree: ElementTree) -> typing.Dict[str,
|
||||||
|
|
||||||
for g in root:
|
for g in root:
|
||||||
name = g.attrib["Name"]
|
name = g.attrib["Name"]
|
||||||
color = g.attrib["Color"]
|
color = g.attrib["Color"] if "Color" in g.attrib else "#00000000"
|
||||||
alpha, red, green, blue = ImageColor.getrgb(color)
|
alpha, red, green, blue = ImageColor.getrgb(color)
|
||||||
colors[name] = red, green, blue, alpha
|
colors[name] = red, green, blue, alpha
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ def get_paint_colors_from_tedit_settings(tree: ElementTree) -> typing.Dict[int,
|
||||||
|
|
||||||
for color in root:
|
for color in root:
|
||||||
id_ = color.attrib["Id"]
|
id_ = color.attrib["Id"]
|
||||||
color = color.attrib["Color"]
|
color = color.attrib["Color"] if "Color" in color.attrib else "#00000000"
|
||||||
alpha, red, green, blue = ImageColor.getrgb(color)
|
alpha, red, green, blue = ImageColor.getrgb(color)
|
||||||
colors[id_] = red, green, blue, alpha
|
colors[id_] = red, green, blue, alpha
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "flyingsnake"
|
name = "flyingsnake"
|
||||||
version = "2.0.0a1"
|
version = "2.0.0a2"
|
||||||
description = "A Terraria world map renderer"
|
description = "A Terraria world map renderer"
|
||||||
authors = ["Stefano Pigozzi <ste.pigozzi@gmail.com>"]
|
authors = ["Stefano Pigozzi <ste.pigozzi@gmail.com>"]
|
||||||
license = "AGPL-3.0+"
|
license = "AGPL-3.0+"
|
||||||
|
|
Loading…
Reference in a new issue