[Polygon / PolyCollection] add raw constructors
This commit is contained in:
parent
ec78031565
commit
27f4f0e86e
2 changed files with 30 additions and 0 deletions
|
|
@ -119,6 +119,22 @@ class PolyCollection(Shape):
|
|||
if numpy.any(offset):
|
||||
self.translate(offset)
|
||||
|
||||
@classmethod
|
||||
def _from_raw(
|
||||
cls,
|
||||
*,
|
||||
vertex_lists: NDArray[numpy.float64],
|
||||
vertex_offsets: NDArray[numpy.integer[Any]],
|
||||
annotations: annotations_t = None,
|
||||
repetition: Repetition | None = None,
|
||||
) -> Self:
|
||||
new = cls.__new__(cls)
|
||||
new._vertex_lists = vertex_lists
|
||||
new._vertex_offsets = vertex_offsets
|
||||
new._repetition = repetition
|
||||
new._annotations = annotations
|
||||
return new
|
||||
|
||||
def __deepcopy__(self, memo: dict | None = None) -> Self:
|
||||
memo = {} if memo is None else memo
|
||||
new = copy.copy(self)
|
||||
|
|
|
|||
|
|
@ -131,6 +131,20 @@ class Polygon(Shape):
|
|||
if numpy.any(offset):
|
||||
self.translate(offset)
|
||||
|
||||
@classmethod
|
||||
def _from_raw(
|
||||
cls,
|
||||
*,
|
||||
vertices: NDArray[numpy.float64],
|
||||
annotations: annotations_t = None,
|
||||
repetition: Repetition | None = None,
|
||||
) -> Self:
|
||||
new = cls.__new__(cls)
|
||||
new._vertices = vertices
|
||||
new._repetition = repetition
|
||||
new._annotations = annotations
|
||||
return new
|
||||
|
||||
def __deepcopy__(self, memo: dict | None = None) -> 'Polygon':
|
||||
memo = {} if memo is None else memo
|
||||
new = copy.copy(self)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue