mirror of
https://github.com/enzet/map-machine.git
synced 2025-05-07 06:07:03 +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).
|
Author: Sergey Vartanov (me@enzet.ru).
|
||||||
"""
|
"""
|
||||||
|
import json
|
||||||
import re
|
import re
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
from pathlib import Path
|
||||||
from typing import Any, Dict, List, Optional, Set
|
from typing import Any, Dict, List, Optional, Set
|
||||||
from xml.dom.minidom import Document, Element, Node, parse
|
from xml.dom.minidom import Document, Element, Node, parse
|
||||||
|
|
||||||
|
@ -12,6 +14,7 @@ import numpy as np
|
||||||
import svgwrite
|
import svgwrite
|
||||||
from colour import Color
|
from colour import Color
|
||||||
from svgwrite import Drawing
|
from svgwrite import Drawing
|
||||||
|
from svgwrite.path import Path as SvgPath
|
||||||
|
|
||||||
from roentgen.color import is_bright
|
from roentgen.color import is_bright
|
||||||
from roentgen.ui import error
|
from roentgen.ui import error
|
||||||
|
@ -45,10 +48,12 @@ class Shape:
|
||||||
return self.id_ in [DEFAULT_SHAPE_ID, DEFAULT_SMALL_SHAPE_ID]
|
return self.id_ in [DEFAULT_SHAPE_ID, DEFAULT_SMALL_SHAPE_ID]
|
||||||
|
|
||||||
def get_path(
|
def get_path(
|
||||||
self, svg: Drawing, point: np.array,
|
self,
|
||||||
|
svg: Drawing,
|
||||||
|
point: np.array,
|
||||||
offset: np.array = np.array((0, 0)),
|
offset: np.array = np.array((0, 0)),
|
||||||
scale: np.array = np.array((1, 1)),
|
scale: np.array = np.array((1, 1)),
|
||||||
):
|
) -> SvgPath:
|
||||||
"""
|
"""
|
||||||
Draw icon into SVG file.
|
Draw icon into SVG file.
|
||||||
|
|
||||||
|
@ -70,6 +75,16 @@ class Shape:
|
||||||
return svg.path(d=self.path, transform=" ".join(transformations))
|
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:
|
class ShapeExtractor:
|
||||||
"""
|
"""
|
||||||
Extract shapes from SVG file.
|
Extract shapes from SVG file.
|
||||||
|
|
Loading…
Add table
Reference in a new issue