add mirror2d() to Rotatable
This commit is contained in:
parent
09a5e4a2db
commit
8e1c05cf73
@ -121,7 +121,7 @@ class Text(RotatableImpl, Shape, metaclass=AutoSlots):
|
|||||||
# Move these polygons to the right of the previous letter
|
# Move these polygons to the right of the previous letter
|
||||||
for xys in raw_polys:
|
for xys in raw_polys:
|
||||||
poly = Polygon(xys, dose=self.dose, layer=self.layer)
|
poly = Polygon(xys, dose=self.dose, layer=self.layer)
|
||||||
[poly.mirror(ax) for ax, do in enumerate(self.mirrored) if do]
|
poly.mirror2d(self.mirrored)
|
||||||
poly.scale_by(self.height)
|
poly.scale_by(self.height)
|
||||||
poly.offset = self.offset + [total_advance, 0]
|
poly.offset = self.offset + [total_advance, 0]
|
||||||
poly.rotate_around(self.offset, self.rotation)
|
poly.rotate_around(self.offset, self.rotation)
|
||||||
|
@ -138,7 +138,7 @@ class SubPattern(PositionableImpl, DoseableImpl, RotatableImpl, ScalableImpl, Mi
|
|||||||
assert(self.pattern is not None)
|
assert(self.pattern is not None)
|
||||||
pattern = self.pattern.deepcopy().deepunlock()
|
pattern = self.pattern.deepcopy().deepunlock()
|
||||||
pattern.scale_by(self.scale)
|
pattern.scale_by(self.scale)
|
||||||
[pattern.mirror(ax) for ax, do in enumerate(self.mirrored) if do]
|
pattern.mirror2d(self.mirrored)
|
||||||
pattern.rotate_around((0.0, 0.0), self.rotation)
|
pattern.rotate_around((0.0, 0.0), self.rotation)
|
||||||
pattern.translate_elements(self.offset)
|
pattern.translate_elements(self.offset)
|
||||||
pattern.scale_element_doses(self.dose)
|
pattern.scale_element_doses(self.dose)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from typing import TypeVar
|
from typing import TypeVar, Tuple
|
||||||
from abc import ABCMeta, abstractmethod
|
from abc import ABCMeta, abstractmethod
|
||||||
|
|
||||||
|
|
||||||
@ -28,6 +28,22 @@ class Mirrorable(metaclass=ABCMeta):
|
|||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def mirror2d(self: T, axes: Tuple[bool, bool]) -> T:
|
||||||
|
"""
|
||||||
|
Optionally mirror the entity across both axes
|
||||||
|
|
||||||
|
Args:
|
||||||
|
axes: (mirror_across_x, mirror_across_y)
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
self
|
||||||
|
"""
|
||||||
|
if axes[0]:
|
||||||
|
self.mirror(0)
|
||||||
|
if axes[1]:
|
||||||
|
self.mirror(1)
|
||||||
|
return self
|
||||||
|
|
||||||
|
|
||||||
#class MirrorableImpl(Mirrorable, metaclass=ABCMeta):
|
#class MirrorableImpl(Mirrorable, metaclass=ABCMeta):
|
||||||
# """
|
# """
|
||||||
|
Loading…
Reference in New Issue
Block a user