start using dataclasses in some places

This commit is contained in:
Laura Klünder 2022-04-07 22:33:25 +02:00
parent 2d4d66b6ef
commit feacd20803

View file

@ -1,5 +1,6 @@
import math import math
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from dataclasses import dataclass
from typing import Optional from typing import Optional
from shapely.geometry import JOIN_STYLE, box from shapely.geometry import JOIN_STYLE, box
@ -7,22 +8,18 @@ from shapely.geometry import JOIN_STYLE, box
from c3nav.mapdata.utils.color import color_to_rgb from c3nav.mapdata.utils.color import color_to_rgb
@dataclass(slots=True)
class FillAttribs: class FillAttribs:
__slots__ = ('color', 'opacity') color: str
opacity: float | None = None
def __init__(self, color, opacity=None):
self.color = color
self.opacity = opacity
@dataclass(slots=True)
class StrokeAttribs: class StrokeAttribs:
__slots__ = ('color', 'width', 'min_px', 'opacity') color: str
width: float
def __init__(self, color, width, min_px=None, opacity=None): min_px: float | None = None
self.color = color opacity: float | None = None
self.width = width
self.min_px = min_px
self.opacity = opacity
class RenderEngine(ABC): class RenderEngine(ABC):