mirror of
https://github.com/enzet/map-machine.git
synced 2025-07-20 09:57:45 +02:00
Fix code style.
This commit is contained in:
parent
913ac05f23
commit
f835aa1701
1 changed files with 20 additions and 12 deletions
|
@ -1,5 +1,6 @@
|
||||||
"""Buildings on the map."""
|
"""Buildings on the map."""
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
import svgwrite
|
||||||
from colour import Color
|
from colour import Color
|
||||||
from svgwrite import Drawing
|
from svgwrite import Drawing
|
||||||
from svgwrite.container import Group
|
from svgwrite.container import Group
|
||||||
|
@ -167,37 +168,44 @@ class Building(Figure):
|
||||||
svg.add(path)
|
svg.add(path)
|
||||||
|
|
||||||
|
|
||||||
def draw_walls(svg, building: Building, segment, height, shift_1, shift_2):
|
def draw_walls(
|
||||||
|
svg: svgwrite.Drawing,
|
||||||
|
building: Building,
|
||||||
|
segment: Segment,
|
||||||
|
height: float,
|
||||||
|
shift_1: np.ndarray,
|
||||||
|
shift_2: np.ndarray,
|
||||||
|
):
|
||||||
"""
|
"""
|
||||||
Draw walls for buildings as a quadrangle.
|
Draw walls for buildings as a quadrangle.
|
||||||
|
|
||||||
Color of the wall is based on illumination.
|
Color of the wall is based on illumination.
|
||||||
"""
|
"""
|
||||||
fill: str
|
color: Color
|
||||||
if building.is_construction:
|
if building.is_construction:
|
||||||
color_part: float = segment.angle * 0.2
|
color_part: float = segment.angle * 0.2
|
||||||
fill = Color(
|
color = Color(
|
||||||
rgb=(
|
rgb=(
|
||||||
building.wall_color.get_red() + color_part,
|
building.wall_color.get_red() + color_part,
|
||||||
building.wall_color.get_green() + color_part,
|
building.wall_color.get_green() + color_part,
|
||||||
building.wall_color.get_blue() + color_part,
|
building.wall_color.get_blue() + color_part,
|
||||||
)
|
)
|
||||||
).hex
|
)
|
||||||
elif height <= 0.25 / BUILDING_SCALE:
|
elif height <= 0.25 / BUILDING_SCALE:
|
||||||
fill = building.wall_bottom_color_1.hex
|
color = building.wall_bottom_color_1
|
||||||
elif height <= 0.5 / BUILDING_SCALE:
|
elif height <= 0.5 / BUILDING_SCALE:
|
||||||
fill = building.wall_bottom_color_2.hex
|
color = building.wall_bottom_color_2
|
||||||
else:
|
else:
|
||||||
color_part: float = segment.angle * 0.2 - 0.1
|
color_part: float = segment.angle * 0.2 - 0.1
|
||||||
fill = Color(
|
color = Color(
|
||||||
rgb=(
|
rgb=(
|
||||||
max(min(building.wall_color.get_red() + color_part, 1), 0),
|
max(min(building.wall_color.get_red() + color_part, 1), 0),
|
||||||
max(min(building.wall_color.get_green() + color_part, 1), 0),
|
max(min(building.wall_color.get_green() + color_part, 1), 0),
|
||||||
max(min(building.wall_color.get_blue() + color_part, 1), 0),
|
max(min(building.wall_color.get_blue() + color_part, 1), 0),
|
||||||
)
|
)
|
||||||
).hex
|
)
|
||||||
|
|
||||||
command = (
|
command: PathCommands = [
|
||||||
"M",
|
"M",
|
||||||
segment.point_1 + shift_1,
|
segment.point_1 + shift_1,
|
||||||
"L",
|
"L",
|
||||||
|
@ -206,11 +214,11 @@ def draw_walls(svg, building: Building, segment, height, shift_1, shift_2):
|
||||||
segment.point_1 + shift_2,
|
segment.point_1 + shift_2,
|
||||||
segment.point_1 + shift_1,
|
segment.point_1 + shift_1,
|
||||||
"Z",
|
"Z",
|
||||||
)
|
]
|
||||||
path: Path = Path(
|
path: Path = Path(
|
||||||
d=command,
|
d=command,
|
||||||
fill=fill,
|
fill=color.hex,
|
||||||
stroke=fill,
|
stroke=color.hex,
|
||||||
stroke_width=1,
|
stroke_width=1,
|
||||||
stroke_linejoin="round",
|
stroke_linejoin="round",
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue