feat: complete S-52 resource contract
This commit is contained in:
@@ -81,6 +81,8 @@ def _line_style_svg(
|
||||
nominal_width = max(1.0, math.floor((dpi / 25.4) / 5.0))
|
||||
current: tuple[float, float] | None = None
|
||||
elements: list[str] = []
|
||||
polygon_mode = False
|
||||
polygon_circles: list[tuple[tuple[float, float], float, str]] = []
|
||||
|
||||
def cv(p: tuple[float, float]) -> tuple[float, float]:
|
||||
return ((p[0] - ox) * unit_to_px, (p[1] - oy) * unit_to_px)
|
||||
@@ -125,13 +127,30 @@ def _line_style_svg(
|
||||
continue
|
||||
cx, cy = cv(current)
|
||||
color = _esc(pen_colors.get(pen_code, next(iter(pen_colors.values()))))
|
||||
stroke = max(1.0, pen_width * nominal_width)
|
||||
elements.append(
|
||||
f'<circle cx="{cx:.3f}" cy="{cy:.3f}" r="{radius:.3f}" fill="none" '
|
||||
f'stroke="{color}" stroke-width="{stroke:.3f}" />'
|
||||
)
|
||||
elif cmd in {"ST", "PM", "FP"}:
|
||||
raise RuntimeError(f"unsupported HPGL {cmd} in line style {name}")
|
||||
if polygon_mode:
|
||||
polygon_circles.append(((cx, cy), radius, color))
|
||||
else:
|
||||
stroke = max(1.0, pen_width * nominal_width)
|
||||
elements.append(
|
||||
f'<circle cx="{cx:.3f}" cy="{cy:.3f}" r="{radius:.3f}" fill="none" '
|
||||
f'stroke="{color}" stroke-width="{stroke:.3f}" />'
|
||||
)
|
||||
elif cmd == "ST":
|
||||
# Symbol transparency command; PLNRTE03 uses ST0 before a filled circle.
|
||||
continue
|
||||
elif cmd == "PM":
|
||||
if arg == "0":
|
||||
polygon_mode = True
|
||||
polygon_circles = []
|
||||
elif arg == "2":
|
||||
polygon_mode = False
|
||||
elif cmd == "FP":
|
||||
for (cx, cy), radius, color in polygon_circles:
|
||||
elements.append(
|
||||
f'<circle cx="{cx:.3f}" cy="{cy:.3f}" r="{radius:.3f}" fill="{color}" />'
|
||||
)
|
||||
polygon_circles = []
|
||||
polygon_mode = False
|
||||
else:
|
||||
raise RuntimeError(f"unsupported HPGL {cmd} in line style {name}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user