mirror of
https://github.com/enzet/map-machine.git
synced 2025-05-01 19:27:06 +02:00
Support crater drawing.
This commit is contained in:
parent
7fcfc85d44
commit
2f80f532ef
6 changed files with 69 additions and 10 deletions
|
@ -145,12 +145,12 @@
|
||||||
inkscape:object-paths="true"
|
inkscape:object-paths="true"
|
||||||
inkscape:guide-bbox="true"
|
inkscape:guide-bbox="true"
|
||||||
showguides="false"
|
showguides="false"
|
||||||
showgrid="false"
|
showgrid="true"
|
||||||
inkscape:document-units="px"
|
inkscape:document-units="px"
|
||||||
inkscape:current-layer="layer1"
|
inkscape:current-layer="layer1"
|
||||||
inkscape:cy="552.05466"
|
inkscape:cy="574.09971"
|
||||||
inkscape:cx="725.47613"
|
inkscape:cx="310.47613"
|
||||||
inkscape:zoom="1"
|
inkscape:zoom="45.254834"
|
||||||
inkscape:pageshadow="2"
|
inkscape:pageshadow="2"
|
||||||
inkscape:pageopacity="0.0"
|
inkscape:pageopacity="0.0"
|
||||||
borderopacity="1.0"
|
borderopacity="1.0"
|
||||||
|
@ -22742,5 +22742,21 @@
|
||||||
<title
|
<title
|
||||||
id="title7808">orbiter</title>
|
id="title7808">orbiter</title>
|
||||||
</path>
|
</path>
|
||||||
|
<path
|
||||||
|
style="opacity:0.2;fill:none;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
|
||||||
|
d="m 306.5,12.5 11,0 c -1.5,-1 -1.5,-2 -2,-3 -2,1.5 -5,1.5 -7,0 -0.5,1 -0.5,2 -2,3 z"
|
||||||
|
id="path7810"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="ccccc" />
|
||||||
|
<path
|
||||||
|
style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;baseline-shift:baseline;text-anchor:start;white-space:normal;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
|
||||||
|
d="m 308.47266,25 c -0.17969,0.01014 -0.34006,0.116064 -0.41993,0.277344 -0.55962,1.119257 -0.45808,1.891979 -1.83007,2.80664 C 305.81126,28.358467 306.00544,28.999813 306.5,29 l 11,0 c 0.49456,-1.87e-4 0.68874,-0.641533 0.27734,-0.916016 -1.37199,-0.914661 -1.27045,-1.687383 -1.83007,-2.80664 -0.13896,-0.28007 -0.49797,-0.36537 -0.74805,-0.177735 -1.808,1.356 -4.59044,1.356 -6.39844,0 -0.0942,-0.07084 -0.21043,-0.106117 -0.32812,-0.09961 z"
|
||||||
|
id="crater"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="cccccccccc"
|
||||||
|
inkscape:label="#path7812">
|
||||||
|
<title
|
||||||
|
id="title7816">crater</title>
|
||||||
|
</path>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
|
|
Before Width: | Height: | Size: 1.3 MiB After Width: | Height: | Size: 1.3 MiB |
|
@ -11,7 +11,14 @@ from colour import Color
|
||||||
|
|
||||||
from roentgen import ui
|
from roentgen import ui
|
||||||
from roentgen.color import get_gradient_color
|
from roentgen.color import get_gradient_color
|
||||||
from roentgen.figure import Building, DirectionSector, Road, StyledFigure, Tree
|
from roentgen.figure import (
|
||||||
|
Building,
|
||||||
|
Crater,
|
||||||
|
DirectionSector,
|
||||||
|
Road,
|
||||||
|
StyledFigure,
|
||||||
|
Tree,
|
||||||
|
)
|
||||||
from roentgen.flinger import Flinger
|
from roentgen.flinger import Flinger
|
||||||
from roentgen.map_configuration import DrawingMode, MapConfiguration
|
from roentgen.map_configuration import DrawingMode, MapConfiguration
|
||||||
|
|
||||||
|
@ -159,6 +166,7 @@ class Constructor:
|
||||||
self.buildings: list[Building] = []
|
self.buildings: list[Building] = []
|
||||||
self.roads: list[Road] = []
|
self.roads: list[Road] = []
|
||||||
self.trees: list[Tree] = []
|
self.trees: list[Tree] = []
|
||||||
|
self.craters: list[Crater] = []
|
||||||
self.direction_sectors: list[DirectionSector] = []
|
self.direction_sectors: list[DirectionSector] = []
|
||||||
|
|
||||||
self.heights: set[float] = {2, 4}
|
self.heights: set[float] = {2, 4}
|
||||||
|
@ -411,6 +419,10 @@ class Constructor:
|
||||||
self.trees.append(Tree(tags, node.coordinates, flung))
|
self.trees.append(Tree(tags, node.coordinates, flung))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if node.get_tag("natural") == "crater" and "diameter" in node.tags:
|
||||||
|
self.craters.append(Crater(tags, node.coordinates, flung))
|
||||||
|
return
|
||||||
|
|
||||||
if "direction" in node.tags or "camera:direction" in node.tags:
|
if "direction" in node.tags or "camera:direction" in node.tags:
|
||||||
self.direction_sectors.append(DirectionSector(tags, flung))
|
self.direction_sectors.append(DirectionSector(tags, flung))
|
||||||
point: Point = Point(
|
point: Point = Point(
|
||||||
|
|
|
@ -247,6 +247,33 @@ class Road(Figure):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class Crater(Tagged):
|
||||||
|
"""
|
||||||
|
Volcano or impact crater on the map.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self, tags: dict[str, str], coordinates: np.ndarray, point: np.ndarray
|
||||||
|
) -> None:
|
||||||
|
super().__init__(tags)
|
||||||
|
self.coordinates: np.ndarray = coordinates
|
||||||
|
self.point: np.ndarray = point
|
||||||
|
|
||||||
|
def draw(self, svg: Drawing, flinger: Flinger) -> None:
|
||||||
|
"""Draw crater ridge."""
|
||||||
|
scale: float = flinger.get_scale(self.coordinates)
|
||||||
|
assert "diameter" in self.tags
|
||||||
|
radius: float = float(self.tags["diameter"]) / 2.0
|
||||||
|
circle = svg.circle(
|
||||||
|
self.point,
|
||||||
|
radius * scale,
|
||||||
|
fill="none",
|
||||||
|
stroke="#000000",
|
||||||
|
opacity=0.3,
|
||||||
|
)
|
||||||
|
svg.add(circle)
|
||||||
|
|
||||||
|
|
||||||
class Tree(Tagged):
|
class Tree(Tagged):
|
||||||
"""
|
"""
|
||||||
Tree on the map.
|
Tree on the map.
|
||||||
|
|
|
@ -357,19 +357,18 @@ class Icon:
|
||||||
:param tags: tags to be displayed as hint
|
:param tags: tags to be displayed as hint
|
||||||
:param outline: draw outline for the icon
|
:param outline: draw outline for the icon
|
||||||
"""
|
"""
|
||||||
target = Group(opacity=self.opacity) if self.opacity != 1.0 else svg
|
|
||||||
if outline:
|
if outline:
|
||||||
bright: bool = is_bright(self.shape_specifications[0].color)
|
bright: bool = is_bright(self.shape_specifications[0].color)
|
||||||
opacity: float = 0.7 if bright else 0.5
|
opacity: float = 0.7 if bright else 0.5
|
||||||
outline_group: Group = Group(opacity=opacity)
|
outline_group: Group = Group(opacity=opacity)
|
||||||
for shape_specification in self.shape_specifications:
|
for shape_specification in self.shape_specifications:
|
||||||
shape_specification.draw(outline_group, point, tags, True)
|
shape_specification.draw(outline_group, point, tags, True)
|
||||||
target.add(outline_group)
|
svg.add(outline_group)
|
||||||
else:
|
else:
|
||||||
|
group: Group = Group(opacity=self.opacity)
|
||||||
for shape_specification in self.shape_specifications:
|
for shape_specification in self.shape_specifications:
|
||||||
shape_specification.draw(target, point, tags)
|
shape_specification.draw(group, point, tags)
|
||||||
if self.opacity != 1.0:
|
svg.add(group)
|
||||||
svg.add(target)
|
|
||||||
|
|
||||||
def draw_to_file(
|
def draw_to_file(
|
||||||
self,
|
self,
|
||||||
|
|
|
@ -80,6 +80,8 @@ class Map:
|
||||||
|
|
||||||
for tree in constructor.trees:
|
for tree in constructor.trees:
|
||||||
tree.draw(self.svg, self.flinger, self.scheme)
|
tree.draw(self.svg, self.flinger, self.scheme)
|
||||||
|
for tree in constructor.craters:
|
||||||
|
tree.draw(self.svg, self.flinger)
|
||||||
|
|
||||||
for direction_sector in constructor.direction_sectors:
|
for direction_sector in constructor.direction_sectors:
|
||||||
direction_sector.draw(self.svg, self.scheme)
|
direction_sector.draw(self.svg, self.scheme)
|
||||||
|
|
|
@ -212,6 +212,9 @@ node_icons:
|
||||||
shapes: [cliff]
|
shapes: [cliff]
|
||||||
- tags: {natural: peak}
|
- tags: {natural: peak}
|
||||||
shapes: [triangle_small]
|
shapes: [triangle_small]
|
||||||
|
- tags: {natural: crater}
|
||||||
|
exception: {diameter: "*"}
|
||||||
|
shapes: [crater]
|
||||||
|
|
||||||
- tags:
|
- tags:
|
||||||
natural: volcano
|
natural: volcano
|
||||||
|
|
Loading…
Add table
Reference in a new issue