[shapes] move to per-shape purpose-built _from_raw constructors
This commit is contained in:
parent
85aed4388e
commit
e009417eed
11 changed files with 290 additions and 141 deletions
|
|
@ -73,27 +73,40 @@ class Text(PositionableImpl, RotatableImpl, Shape):
|
|||
mirrored: bool = False,
|
||||
repetition: Repetition | None = None,
|
||||
annotations: annotations_t = None,
|
||||
raw: bool = False,
|
||||
) -> None:
|
||||
if raw:
|
||||
assert isinstance(offset, numpy.ndarray)
|
||||
self._offset = offset
|
||||
self._string = string
|
||||
self._height = height
|
||||
self._rotation = rotation
|
||||
self._mirrored = mirrored
|
||||
self._repetition = repetition
|
||||
self._annotations = annotations
|
||||
else:
|
||||
self.offset = offset
|
||||
self.string = string
|
||||
self.height = height
|
||||
self.rotation = rotation
|
||||
self.mirrored = mirrored
|
||||
self.repetition = repetition
|
||||
self.annotations = annotations
|
||||
self.offset = offset
|
||||
self.string = string
|
||||
self.height = height
|
||||
self.rotation = rotation
|
||||
self.mirrored = mirrored
|
||||
self.repetition = repetition
|
||||
self.annotations = annotations
|
||||
self.font_path = font_path
|
||||
|
||||
@classmethod
|
||||
def _from_raw(
|
||||
cls,
|
||||
*,
|
||||
string: str,
|
||||
height: float,
|
||||
font_path: str,
|
||||
offset: NDArray[numpy.float64],
|
||||
rotation: float,
|
||||
mirrored: bool,
|
||||
annotations: annotations_t = None,
|
||||
repetition: Repetition | None = None,
|
||||
) -> Self:
|
||||
new = cls.__new__(cls)
|
||||
new._offset = offset
|
||||
new._string = string
|
||||
new._height = height
|
||||
new._rotation = rotation % (2 * pi)
|
||||
new._mirrored = mirrored
|
||||
new._repetition = repetition
|
||||
new._annotations = annotations
|
||||
new.font_path = font_path
|
||||
return new
|
||||
|
||||
def __deepcopy__(self, memo: dict | None = None) -> Self:
|
||||
memo = {} if memo is None else memo
|
||||
new = copy.copy(self)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue