[RectCollection] advise the user what to do if they want to make a non-manhattan rotation
This commit is contained in:
parent
db96464111
commit
d48c0f2879
1 changed files with 6 additions and 1 deletions
|
|
@ -187,7 +187,12 @@ class RectCollection(Shape):
|
||||||
def rotate(self, theta: float) -> Self:
|
def rotate(self, theta: float) -> Self:
|
||||||
quarter_turns = int(numpy.rint(theta / (pi / 2)))
|
quarter_turns = int(numpy.rint(theta / (pi / 2)))
|
||||||
if not numpy.isclose(theta, quarter_turns * (pi / 2)):
|
if not numpy.isclose(theta, quarter_turns * (pi / 2)):
|
||||||
raise PatternError('RectCollection only supports Manhattan rotations')
|
raise PatternError(
|
||||||
|
f'RectCollection cannot rotate by {theta!r} radians; only Manhattan rotations (multiples of pi/2) are supported. '
|
||||||
|
'Explicitly replace the collection with to_polygons(), or call Pattern.polygonize() '
|
||||||
|
'on the pattern containing it (including referenced child patterns) before transforming, '
|
||||||
|
'flattening, or computing hierarchical bounds.'
|
||||||
|
)
|
||||||
turns = quarter_turns % 4
|
turns = quarter_turns % 4
|
||||||
if turns == 0 or self._rects.size == 0:
|
if turns == 0 or self._rects.size == 0:
|
||||||
return self
|
return self
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue