[PolyCollection] many fixes
This commit is contained in:
parent
25cde0abb5
commit
3a73fb1d60
@ -10,6 +10,7 @@ from .shape import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
from .polygon import Polygon as Polygon
|
from .polygon import Polygon as Polygon
|
||||||
|
from .poly_collection import PolyCollection as PolyCollection
|
||||||
from .circle import Circle as Circle
|
from .circle import Circle as Circle
|
||||||
from .ellipse import Ellipse as Ellipse
|
from .ellipse import Ellipse as Ellipse
|
||||||
from .arc import Arc as Arc
|
from .arc import Arc as Arc
|
||||||
|
@ -55,7 +55,11 @@ class PolyCollection(Shape):
|
|||||||
"""
|
"""
|
||||||
Iterator which provides slices which index vertex_lists
|
Iterator which provides slices which index vertex_lists
|
||||||
"""
|
"""
|
||||||
for ii, ff in chain(self._vertex_offsets, (self._vertex_lists.shape[0],)):
|
for ii, ff in zip(
|
||||||
|
self._vertex_offsets,
|
||||||
|
chain(self._vertex_offsets, (self._vertex_lists.shape[0],)),
|
||||||
|
strict=True,
|
||||||
|
):
|
||||||
yield slice(ii, ff)
|
yield slice(ii, ff)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -144,7 +148,7 @@ class PolyCollection(Shape):
|
|||||||
return [Polygon(
|
return [Polygon(
|
||||||
vertices = vv,
|
vertices = vv,
|
||||||
offset = self.offset,
|
offset = self.offset,
|
||||||
repetition = self.repetition.copy(),
|
repetition = copy.deepcopy(self.repetition),
|
||||||
annotations = copy.deepcopy(self.annotations),
|
annotations = copy.deepcopy(self.annotations),
|
||||||
) for vv in self.polygon_vertices]
|
) for vv in self.polygon_vertices]
|
||||||
|
|
||||||
@ -155,7 +159,7 @@ class PolyCollection(Shape):
|
|||||||
def rotate(self, theta: float) -> Self:
|
def rotate(self, theta: float) -> Self:
|
||||||
if theta != 0:
|
if theta != 0:
|
||||||
rot = rotation_matrix_2d(theta)
|
rot = rotation_matrix_2d(theta)
|
||||||
self._vertex_lists = numpy.einsum('ij,kj->ki', rot, self._vertex_lists_)
|
self._vertex_lists = numpy.einsum('ij,kj->ki', rot, self._vertex_lists)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def mirror(self, axis: int = 0) -> Self:
|
def mirror(self, axis: int = 0) -> Self:
|
||||||
@ -163,7 +167,7 @@ class PolyCollection(Shape):
|
|||||||
return self
|
return self
|
||||||
|
|
||||||
def scale_by(self, c: float) -> Self:
|
def scale_by(self, c: float) -> Self:
|
||||||
self.vertex_lists *= c
|
self._vertex_lists *= c
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def normalized_form(self, norm_value: float) -> normalized_shape_tuple:
|
def normalized_form(self, norm_value: float) -> normalized_shape_tuple:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user