mirror of
https://github.com/enzet/map-machine.git
synced 2025-05-03 20:26:45 +02:00
Add shape configuration.
This commit is contained in:
parent
c96462b2ee
commit
77a0c0fdfe
2 changed files with 22 additions and 2 deletions
5
icons/config.json
Normal file
5
icons/config.json
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"right_directed": [
|
||||
"cctv"
|
||||
]
|
||||
}
|
|
@ -3,8 +3,10 @@ Extract icons from SVG file.
|
|||
|
||||
Author: Sergey Vartanov (me@enzet.ru).
|
||||
"""
|
||||
import json
|
||||
import re
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, List, Optional, Set
|
||||
from xml.dom.minidom import Document, Element, Node, parse
|
||||
|
||||
|
@ -12,6 +14,7 @@ import numpy as np
|
|||
import svgwrite
|
||||
from colour import Color
|
||||
from svgwrite import Drawing
|
||||
from svgwrite.path import Path as SvgPath
|
||||
|
||||
from roentgen.color import is_bright
|
||||
from roentgen.ui import error
|
||||
|
@ -45,10 +48,12 @@ class Shape:
|
|||
return self.id_ in [DEFAULT_SHAPE_ID, DEFAULT_SMALL_SHAPE_ID]
|
||||
|
||||
def get_path(
|
||||
self, svg: Drawing, point: np.array,
|
||||
self,
|
||||
svg: Drawing,
|
||||
point: np.array,
|
||||
offset: np.array = np.array((0, 0)),
|
||||
scale: np.array = np.array((1, 1)),
|
||||
):
|
||||
) -> SvgPath:
|
||||
"""
|
||||
Draw icon into SVG file.
|
||||
|
||||
|
@ -70,6 +75,16 @@ class Shape:
|
|||
return svg.path(d=self.path, transform=" ".join(transformations))
|
||||
|
||||
|
||||
class ShapeConfiguration:
|
||||
"""
|
||||
Description of the icon shape properties.
|
||||
"""
|
||||
|
||||
def __init__(self, file_name: Path):
|
||||
content = json.load(file_name)
|
||||
self.right_directed: Set[str] = set(content["right_directed"])
|
||||
|
||||
|
||||
class ShapeExtractor:
|
||||
"""
|
||||
Extract shapes from SVG file.
|
||||
|
|
Loading…
Add table
Reference in a new issue