reformat some multiline arg lists and add missing 'None' return types
This commit is contained in:
parent
250107e41b
commit
89f327ba37
20 changed files with 616 additions and 510 deletions
|
|
@ -51,7 +51,7 @@ class Arc(Shape, metaclass=AutoSlots):
|
|||
return self._radii
|
||||
|
||||
@radii.setter
|
||||
def radii(self, val: vector2):
|
||||
def radii(self, val: vector2) -> None:
|
||||
val = numpy.array(val, dtype=float).flatten()
|
||||
if not val.size == 2:
|
||||
raise PatternError('Radii must have length 2')
|
||||
|
|
@ -64,7 +64,7 @@ class Arc(Shape, metaclass=AutoSlots):
|
|||
return self._radii[0]
|
||||
|
||||
@radius_x.setter
|
||||
def radius_x(self, val: float):
|
||||
def radius_x(self, val: float) -> None:
|
||||
if not val >= 0:
|
||||
raise PatternError('Radius must be non-negative')
|
||||
self._radii[0] = val
|
||||
|
|
@ -74,7 +74,7 @@ class Arc(Shape, metaclass=AutoSlots):
|
|||
return self._radii[1]
|
||||
|
||||
@radius_y.setter
|
||||
def radius_y(self, val: float):
|
||||
def radius_y(self, val: float) -> None:
|
||||
if not val >= 0:
|
||||
raise PatternError('Radius must be non-negative')
|
||||
self._radii[1] = val
|
||||
|
|
@ -92,7 +92,7 @@ class Arc(Shape, metaclass=AutoSlots):
|
|||
return self._angles
|
||||
|
||||
@angles.setter
|
||||
def angles(self, val: vector2):
|
||||
def angles(self, val: vector2) -> None:
|
||||
val = numpy.array(val, dtype=float).flatten()
|
||||
if not val.size == 2:
|
||||
raise PatternError('Angles must have length 2')
|
||||
|
|
@ -103,7 +103,7 @@ class Arc(Shape, metaclass=AutoSlots):
|
|||
return self.angles[0]
|
||||
|
||||
@start_angle.setter
|
||||
def start_angle(self, val: float):
|
||||
def start_angle(self, val: float) -> None:
|
||||
self.angles = (val, self.angles[1])
|
||||
|
||||
@property
|
||||
|
|
@ -111,7 +111,7 @@ class Arc(Shape, metaclass=AutoSlots):
|
|||
return self.angles[1]
|
||||
|
||||
@stop_angle.setter
|
||||
def stop_angle(self, val: float):
|
||||
def stop_angle(self, val: float) -> None:
|
||||
self.angles = (self.angles[0], val)
|
||||
|
||||
# Rotation property
|
||||
|
|
@ -126,7 +126,7 @@ class Arc(Shape, metaclass=AutoSlots):
|
|||
return self._rotation
|
||||
|
||||
@rotation.setter
|
||||
def rotation(self, val: float):
|
||||
def rotation(self, val: float) -> None:
|
||||
if not is_scalar(val):
|
||||
raise PatternError('Rotation must be a scalar')
|
||||
self._rotation = val % (2 * pi)
|
||||
|
|
@ -143,30 +143,31 @@ class Arc(Shape, metaclass=AutoSlots):
|
|||
return self._width
|
||||
|
||||
@width.setter
|
||||
def width(self, val: float):
|
||||
def width(self, val: float) -> None:
|
||||
if not is_scalar(val):
|
||||
raise PatternError('Width must be a scalar')
|
||||
if not val > 0:
|
||||
raise PatternError('Width must be positive')
|
||||
self._width = val
|
||||
|
||||
def __init__(self,
|
||||
radii: vector2,
|
||||
angles: vector2,
|
||||
width: float,
|
||||
*,
|
||||
poly_num_points: Optional[int] = DEFAULT_POLY_NUM_POINTS,
|
||||
poly_max_arclen: Optional[float] = None,
|
||||
offset: vector2 = (0.0, 0.0),
|
||||
rotation: float = 0,
|
||||
mirrored: Sequence[bool] = (False, False),
|
||||
layer: layer_t = 0,
|
||||
dose: float = 1.0,
|
||||
repetition: Optional[Repetition] = None,
|
||||
annotations: Optional[annotations_t] = None,
|
||||
locked: bool = False,
|
||||
raw: bool = False,
|
||||
):
|
||||
def __init__(
|
||||
self,
|
||||
radii: vector2,
|
||||
angles: vector2,
|
||||
width: float,
|
||||
*,
|
||||
poly_num_points: Optional[int] = DEFAULT_POLY_NUM_POINTS,
|
||||
poly_max_arclen: Optional[float] = None,
|
||||
offset: vector2 = (0.0, 0.0),
|
||||
rotation: float = 0,
|
||||
mirrored: Sequence[bool] = (False, False),
|
||||
layer: layer_t = 0,
|
||||
dose: float = 1.0,
|
||||
repetition: Optional[Repetition] = None,
|
||||
annotations: Optional[annotations_t] = None,
|
||||
locked: bool = False,
|
||||
raw: bool = False,
|
||||
) -> None:
|
||||
LockableImpl.unlock(self)
|
||||
self.identifier = ()
|
||||
if raw:
|
||||
|
|
@ -204,10 +205,11 @@ class Arc(Shape, metaclass=AutoSlots):
|
|||
new.set_locked(self.locked)
|
||||
return new
|
||||
|
||||
def to_polygons(self,
|
||||
poly_num_points: Optional[int] = None,
|
||||
poly_max_arclen: Optional[float] = None,
|
||||
) -> List[Polygon]:
|
||||
def to_polygons(
|
||||
self,
|
||||
poly_num_points: Optional[int] = None,
|
||||
poly_max_arclen: Optional[float] = None,
|
||||
) -> List[Polygon]:
|
||||
if poly_num_points is None:
|
||||
poly_num_points = self.poly_num_points
|
||||
if poly_max_arclen is None:
|
||||
|
|
|
|||
|
|
@ -35,26 +35,27 @@ class Circle(Shape, metaclass=AutoSlots):
|
|||
return self._radius
|
||||
|
||||
@radius.setter
|
||||
def radius(self, val: float):
|
||||
def radius(self, val: float) -> None:
|
||||
if not is_scalar(val):
|
||||
raise PatternError('Radius must be a scalar')
|
||||
if not val >= 0:
|
||||
raise PatternError('Radius must be non-negative')
|
||||
self._radius = val
|
||||
|
||||
def __init__(self,
|
||||
radius: float,
|
||||
*,
|
||||
poly_num_points: Optional[int] = DEFAULT_POLY_NUM_POINTS,
|
||||
poly_max_arclen: Optional[float] = None,
|
||||
offset: vector2 = (0.0, 0.0),
|
||||
layer: layer_t = 0,
|
||||
dose: float = 1.0,
|
||||
repetition: Optional[Repetition] = None,
|
||||
annotations: Optional[annotations_t] = None,
|
||||
locked: bool = False,
|
||||
raw: bool = False,
|
||||
):
|
||||
def __init__(
|
||||
self,
|
||||
radius: float,
|
||||
*,
|
||||
poly_num_points: Optional[int] = DEFAULT_POLY_NUM_POINTS,
|
||||
poly_max_arclen: Optional[float] = None,
|
||||
offset: vector2 = (0.0, 0.0),
|
||||
layer: layer_t = 0,
|
||||
dose: float = 1.0,
|
||||
repetition: Optional[Repetition] = None,
|
||||
annotations: Optional[annotations_t] = None,
|
||||
locked: bool = False,
|
||||
raw: bool = False,
|
||||
) -> None:
|
||||
LockableImpl.unlock(self)
|
||||
self.identifier = ()
|
||||
if raw:
|
||||
|
|
@ -83,10 +84,11 @@ class Circle(Shape, metaclass=AutoSlots):
|
|||
new.set_locked(self.locked)
|
||||
return new
|
||||
|
||||
def to_polygons(self,
|
||||
poly_num_points: Optional[int] = None,
|
||||
poly_max_arclen: Optional[float] = None,
|
||||
) -> List[Polygon]:
|
||||
def to_polygons(
|
||||
self,
|
||||
poly_num_points: Optional[int] = None,
|
||||
poly_max_arclen: Optional[float] = None,
|
||||
) -> List[Polygon]:
|
||||
if poly_num_points is None:
|
||||
poly_num_points = self.poly_num_points
|
||||
if poly_max_arclen is None:
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class Ellipse(Shape, metaclass=AutoSlots):
|
|||
return self._radii
|
||||
|
||||
@radii.setter
|
||||
def radii(self, val: vector2):
|
||||
def radii(self, val: vector2) -> None:
|
||||
val = numpy.array(val).flatten()
|
||||
if not val.size == 2:
|
||||
raise PatternError('Radii must have length 2')
|
||||
|
|
@ -54,7 +54,7 @@ class Ellipse(Shape, metaclass=AutoSlots):
|
|||
return self.radii[0]
|
||||
|
||||
@radius_x.setter
|
||||
def radius_x(self, val: float):
|
||||
def radius_x(self, val: float) -> None:
|
||||
if not val >= 0:
|
||||
raise PatternError('Radius must be non-negative')
|
||||
self.radii[0] = val
|
||||
|
|
@ -64,7 +64,7 @@ class Ellipse(Shape, metaclass=AutoSlots):
|
|||
return self.radii[1]
|
||||
|
||||
@radius_y.setter
|
||||
def radius_y(self, val: float):
|
||||
def radius_y(self, val: float) -> None:
|
||||
if not val >= 0:
|
||||
raise PatternError('Radius must be non-negative')
|
||||
self.radii[1] = val
|
||||
|
|
@ -82,26 +82,27 @@ class Ellipse(Shape, metaclass=AutoSlots):
|
|||
return self._rotation
|
||||
|
||||
@rotation.setter
|
||||
def rotation(self, val: float):
|
||||
def rotation(self, val: float) -> None:
|
||||
if not is_scalar(val):
|
||||
raise PatternError('Rotation must be a scalar')
|
||||
self._rotation = val % pi
|
||||
|
||||
def __init__(self,
|
||||
radii: vector2,
|
||||
*,
|
||||
poly_num_points: Optional[int] = DEFAULT_POLY_NUM_POINTS,
|
||||
poly_max_arclen: Optional[float] = None,
|
||||
offset: vector2 = (0.0, 0.0),
|
||||
rotation: float = 0,
|
||||
mirrored: Sequence[bool] = (False, False),
|
||||
layer: layer_t = 0,
|
||||
dose: float = 1.0,
|
||||
repetition: Optional[Repetition] = None,
|
||||
annotations: Optional[annotations_t] = None,
|
||||
locked: bool = False,
|
||||
raw: bool = False,
|
||||
):
|
||||
def __init__(
|
||||
self,
|
||||
radii: vector2,
|
||||
*,
|
||||
poly_num_points: Optional[int] = DEFAULT_POLY_NUM_POINTS,
|
||||
poly_max_arclen: Optional[float] = None,
|
||||
offset: vector2 = (0.0, 0.0),
|
||||
rotation: float = 0,
|
||||
mirrored: Sequence[bool] = (False, False),
|
||||
layer: layer_t = 0,
|
||||
dose: float = 1.0,
|
||||
repetition: Optional[Repetition] = None,
|
||||
annotations: Optional[annotations_t] = None,
|
||||
locked: bool = False,
|
||||
raw: bool = False,
|
||||
) -> None:
|
||||
LockableImpl.unlock(self)
|
||||
self.identifier = ()
|
||||
if raw:
|
||||
|
|
@ -134,10 +135,11 @@ class Ellipse(Shape, metaclass=AutoSlots):
|
|||
new.set_locked(self.locked)
|
||||
return new
|
||||
|
||||
def to_polygons(self,
|
||||
poly_num_points: Optional[int] = None,
|
||||
poly_max_arclen: Optional[float] = None,
|
||||
) -> List[Polygon]:
|
||||
def to_polygons(
|
||||
self,
|
||||
poly_num_points: Optional[int] = None,
|
||||
poly_max_arclen: Optional[float] = None,
|
||||
) -> List[Polygon]:
|
||||
if poly_num_points is None:
|
||||
poly_num_points = self.poly_num_points
|
||||
if poly_max_arclen is None:
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ class Path(Shape, metaclass=AutoSlots):
|
|||
return self._width
|
||||
|
||||
@width.setter
|
||||
def width(self, val: float):
|
||||
def width(self, val: float) -> None:
|
||||
if not is_scalar(val):
|
||||
raise PatternError('Width must be a scalar')
|
||||
if not val >= 0:
|
||||
|
|
@ -62,7 +62,7 @@ class Path(Shape, metaclass=AutoSlots):
|
|||
return self._cap
|
||||
|
||||
@cap.setter
|
||||
def cap(self, val: PathCap):
|
||||
def cap(self, val: PathCap) -> None:
|
||||
# TODO: Document that setting cap can change cap_extensions
|
||||
self._cap = PathCap(val)
|
||||
if self.cap != PathCap.SquareCustom:
|
||||
|
|
@ -83,7 +83,7 @@ class Path(Shape, metaclass=AutoSlots):
|
|||
return self._cap_extensions
|
||||
|
||||
@cap_extensions.setter
|
||||
def cap_extensions(self, vals: Optional[numpy.ndarray]):
|
||||
def cap_extensions(self, vals: Optional[numpy.ndarray]) -> None:
|
||||
custom_caps = (PathCap.SquareCustom,)
|
||||
if self.cap in custom_caps:
|
||||
if vals is None:
|
||||
|
|
@ -103,7 +103,7 @@ class Path(Shape, metaclass=AutoSlots):
|
|||
return self._vertices
|
||||
|
||||
@vertices.setter
|
||||
def vertices(self, val: ArrayLike):
|
||||
def vertices(self, val: ArrayLike) -> None:
|
||||
val = numpy.array(val, dtype=float) # TODO document that these might not be copied
|
||||
if len(val.shape) < 2 or val.shape[1] != 2:
|
||||
raise PatternError('Vertices must be an Nx2 array')
|
||||
|
|
@ -120,7 +120,7 @@ class Path(Shape, metaclass=AutoSlots):
|
|||
return self.vertices[:, 0]
|
||||
|
||||
@xs.setter
|
||||
def xs(self, val: ArrayLike):
|
||||
def xs(self, val: ArrayLike) -> None:
|
||||
val = numpy.array(val, dtype=float).flatten()
|
||||
if val.size != self.vertices.shape[0]:
|
||||
raise PatternError('Wrong number of vertices')
|
||||
|
|
@ -135,28 +135,29 @@ class Path(Shape, metaclass=AutoSlots):
|
|||
return self.vertices[:, 1]
|
||||
|
||||
@ys.setter
|
||||
def ys(self, val: ArrayLike):
|
||||
def ys(self, val: ArrayLike) -> None:
|
||||
val = numpy.array(val, dtype=float).flatten()
|
||||
if val.size != self.vertices.shape[0]:
|
||||
raise PatternError('Wrong number of vertices')
|
||||
self.vertices[:, 1] = val
|
||||
|
||||
def __init__(self,
|
||||
vertices: ArrayLike,
|
||||
width: float = 0.0,
|
||||
*,
|
||||
cap: PathCap = PathCap.Flush,
|
||||
cap_extensions: Optional[ArrayLike] = None,
|
||||
offset: vector2 = (0.0, 0.0),
|
||||
rotation: float = 0,
|
||||
mirrored: Sequence[bool] = (False, False),
|
||||
layer: layer_t = 0,
|
||||
dose: float = 1.0,
|
||||
repetition: Optional[Repetition] = None,
|
||||
annotations: Optional[annotations_t] = None,
|
||||
locked: bool = False,
|
||||
raw: bool = False,
|
||||
):
|
||||
def __init__(
|
||||
self,
|
||||
vertices: ArrayLike,
|
||||
width: float = 0.0,
|
||||
*,
|
||||
cap: PathCap = PathCap.Flush,
|
||||
cap_extensions: Optional[ArrayLike] = None,
|
||||
offset: vector2 = (0.0, 0.0),
|
||||
rotation: float = 0,
|
||||
mirrored: Sequence[bool] = (False, False),
|
||||
layer: layer_t = 0,
|
||||
dose: float = 1.0,
|
||||
repetition: Optional[Repetition] = None,
|
||||
annotations: Optional[annotations_t] = None,
|
||||
locked: bool = False,
|
||||
raw: bool = False,
|
||||
) -> None:
|
||||
LockableImpl.unlock(self)
|
||||
self._cap_extensions = None # Since .cap setter might access it
|
||||
|
||||
|
|
@ -197,16 +198,17 @@ class Path(Shape, metaclass=AutoSlots):
|
|||
return new
|
||||
|
||||
@staticmethod
|
||||
def travel(travel_pairs: Tuple[Tuple[float, float]],
|
||||
width: float = 0.0,
|
||||
cap: PathCap = PathCap.Flush,
|
||||
cap_extensions: Optional[Tuple[float, float]] = None,
|
||||
offset: vector2 = (0.0, 0.0),
|
||||
rotation: float = 0,
|
||||
mirrored: Sequence[bool] = (False, False),
|
||||
layer: layer_t = 0,
|
||||
dose: float = 1.0,
|
||||
) -> 'Path':
|
||||
def travel(
|
||||
travel_pairs: Tuple[Tuple[float, float]],
|
||||
width: float = 0.0,
|
||||
cap: PathCap = PathCap.Flush,
|
||||
cap_extensions: Optional[Tuple[float, float]] = None,
|
||||
offset: vector2 = (0.0, 0.0),
|
||||
rotation: float = 0,
|
||||
mirrored: Sequence[bool] = (False, False),
|
||||
layer: layer_t = 0,
|
||||
dose: float = 1.0,
|
||||
) -> 'Path':
|
||||
"""
|
||||
Build a path by specifying the turn angles and travel distances
|
||||
rather than setting the distances directly.
|
||||
|
|
@ -243,10 +245,11 @@ class Path(Shape, metaclass=AutoSlots):
|
|||
offset=offset, rotation=rotation, mirrored=mirrored,
|
||||
layer=layer, dose=dose)
|
||||
|
||||
def to_polygons(self,
|
||||
poly_num_points: int = None,
|
||||
poly_max_arclen: float = None,
|
||||
) -> List['Polygon']:
|
||||
def to_polygons(
|
||||
self,
|
||||
poly_num_points: int = None,
|
||||
poly_max_arclen: float = None,
|
||||
) -> List['Polygon']:
|
||||
extensions = self._calculate_cap_extensions()
|
||||
|
||||
v = remove_colinear_vertices(self.vertices, closed_path=False)
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class Polygon(Shape, metaclass=AutoSlots):
|
|||
return self._vertices
|
||||
|
||||
@vertices.setter
|
||||
def vertices(self, val: ArrayLike):
|
||||
def vertices(self, val: ArrayLike) -> None:
|
||||
val = numpy.array(val, dtype=float) # TODO document that these might not be copied
|
||||
if len(val.shape) < 2 or val.shape[1] != 2:
|
||||
raise PatternError('Vertices must be an Nx2 array')
|
||||
|
|
@ -51,7 +51,7 @@ class Polygon(Shape, metaclass=AutoSlots):
|
|||
return self.vertices[:, 0]
|
||||
|
||||
@xs.setter
|
||||
def xs(self, val: ArrayLike):
|
||||
def xs(self, val: ArrayLike) -> None:
|
||||
val = numpy.array(val, dtype=float).flatten()
|
||||
if val.size != self.vertices.shape[0]:
|
||||
raise PatternError('Wrong number of vertices')
|
||||
|
|
@ -66,25 +66,26 @@ class Polygon(Shape, metaclass=AutoSlots):
|
|||
return self.vertices[:, 1]
|
||||
|
||||
@ys.setter
|
||||
def ys(self, val: ArrayLike):
|
||||
def ys(self, val: ArrayLike) -> None:
|
||||
val = numpy.array(val, dtype=float).flatten()
|
||||
if val.size != self.vertices.shape[0]:
|
||||
raise PatternError('Wrong number of vertices')
|
||||
self.vertices[:, 1] = val
|
||||
|
||||
def __init__(self,
|
||||
vertices: ArrayLike,
|
||||
*,
|
||||
offset: vector2 = (0.0, 0.0),
|
||||
rotation: float = 0.0,
|
||||
mirrored: Sequence[bool] = (False, False),
|
||||
layer: layer_t = 0,
|
||||
dose: float = 1.0,
|
||||
repetition: Optional[Repetition] = None,
|
||||
annotations: Optional[annotations_t] = None,
|
||||
locked: bool = False,
|
||||
raw: bool = False,
|
||||
):
|
||||
def __init__(
|
||||
self,
|
||||
vertices: ArrayLike,
|
||||
*,
|
||||
offset: vector2 = (0.0, 0.0),
|
||||
rotation: float = 0.0,
|
||||
mirrored: Sequence[bool] = (False, False),
|
||||
layer: layer_t = 0,
|
||||
dose: float = 1.0,
|
||||
repetition: Optional[Repetition] = None,
|
||||
annotations: Optional[annotations_t] = None,
|
||||
locked: bool = False,
|
||||
raw: bool = False,
|
||||
) -> None:
|
||||
LockableImpl.unlock(self)
|
||||
self.identifier = ()
|
||||
if raw:
|
||||
|
|
@ -115,14 +116,15 @@ class Polygon(Shape, metaclass=AutoSlots):
|
|||
return new
|
||||
|
||||
@staticmethod
|
||||
def square(side_length: float,
|
||||
*,
|
||||
rotation: float = 0.0,
|
||||
offset: vector2 = (0.0, 0.0),
|
||||
layer: layer_t = 0,
|
||||
dose: float = 1.0,
|
||||
repetition: Optional[Repetition] = None,
|
||||
) -> 'Polygon':
|
||||
def square(
|
||||
side_length: float,
|
||||
*,
|
||||
rotation: float = 0.0,
|
||||
offset: vector2 = (0.0, 0.0),
|
||||
layer: layer_t = 0,
|
||||
dose: float = 1.0,
|
||||
repetition: Optional[Repetition] = None,
|
||||
) -> 'Polygon':
|
||||
"""
|
||||
Draw a square given side_length, centered on the origin.
|
||||
|
||||
|
|
@ -148,15 +150,16 @@ class Polygon(Shape, metaclass=AutoSlots):
|
|||
return poly
|
||||
|
||||
@staticmethod
|
||||
def rectangle(lx: float,
|
||||
ly: float,
|
||||
*,
|
||||
rotation: float = 0,
|
||||
offset: vector2 = (0.0, 0.0),
|
||||
layer: layer_t = 0,
|
||||
dose: float = 1.0,
|
||||
repetition: Optional[Repetition] = None,
|
||||
) -> 'Polygon':
|
||||
def rectangle(
|
||||
lx: float,
|
||||
ly: float,
|
||||
*,
|
||||
rotation: float = 0,
|
||||
offset: vector2 = (0.0, 0.0),
|
||||
layer: layer_t = 0,
|
||||
dose: float = 1.0,
|
||||
repetition: Optional[Repetition] = None,
|
||||
) -> 'Polygon':
|
||||
"""
|
||||
Draw a rectangle with side lengths lx and ly, centered on the origin.
|
||||
|
||||
|
|
@ -182,19 +185,20 @@ class Polygon(Shape, metaclass=AutoSlots):
|
|||
return poly
|
||||
|
||||
@staticmethod
|
||||
def rect(*,
|
||||
xmin: Optional[float] = None,
|
||||
xctr: Optional[float] = None,
|
||||
xmax: Optional[float] = None,
|
||||
lx: Optional[float] = None,
|
||||
ymin: Optional[float] = None,
|
||||
yctr: Optional[float] = None,
|
||||
ymax: Optional[float] = None,
|
||||
ly: Optional[float] = None,
|
||||
layer: layer_t = 0,
|
||||
dose: float = 1.0,
|
||||
repetition: Optional[Repetition] = None,
|
||||
) -> 'Polygon':
|
||||
def rect(
|
||||
*,
|
||||
xmin: Optional[float] = None,
|
||||
xctr: Optional[float] = None,
|
||||
xmax: Optional[float] = None,
|
||||
lx: Optional[float] = None,
|
||||
ymin: Optional[float] = None,
|
||||
yctr: Optional[float] = None,
|
||||
ymax: Optional[float] = None,
|
||||
ly: Optional[float] = None,
|
||||
layer: layer_t = 0,
|
||||
dose: float = 1.0,
|
||||
repetition: Optional[Repetition] = None,
|
||||
) -> 'Polygon':
|
||||
"""
|
||||
Draw a rectangle by specifying side/center positions.
|
||||
|
||||
|
|
@ -282,16 +286,17 @@ class Polygon(Shape, metaclass=AutoSlots):
|
|||
return poly
|
||||
|
||||
@staticmethod
|
||||
def octagon(*,
|
||||
side_length: Optional[float] = None,
|
||||
inner_radius: Optional[float] = None,
|
||||
regular: bool = True,
|
||||
center: vector2 = (0.0, 0.0),
|
||||
rotation: float = 0.0,
|
||||
layer: layer_t = 0,
|
||||
dose: float = 1.0,
|
||||
repetition: Optional[Repetition] = None,
|
||||
) -> 'Polygon':
|
||||
def octagon(
|
||||
*,
|
||||
side_length: Optional[float] = None,
|
||||
inner_radius: Optional[float] = None,
|
||||
regular: bool = True,
|
||||
center: vector2 = (0.0, 0.0),
|
||||
rotation: float = 0.0,
|
||||
layer: layer_t = 0,
|
||||
dose: float = 1.0,
|
||||
repetition: Optional[Repetition] = None,
|
||||
) -> 'Polygon':
|
||||
"""
|
||||
Draw an octagon given one of (side length, inradius, circumradius).
|
||||
|
||||
|
|
@ -341,10 +346,11 @@ class Polygon(Shape, metaclass=AutoSlots):
|
|||
return poly
|
||||
|
||||
|
||||
def to_polygons(self,
|
||||
poly_num_points: int = None, # unused
|
||||
poly_max_arclen: float = None, # unused
|
||||
) -> List['Polygon']:
|
||||
def to_polygons(
|
||||
self,
|
||||
poly_num_points: int = None, # unused
|
||||
poly_max_arclen: float = None, # unused
|
||||
) -> List['Polygon']:
|
||||
return [copy.deepcopy(self)]
|
||||
|
||||
def get_bounds(self) -> numpy.ndarray:
|
||||
|
|
|
|||
|
|
@ -47,10 +47,11 @@ class Shape(PositionableImpl, LayerableImpl, DoseableImpl, Rotatable, Mirrorable
|
|||
--- Abstract methods
|
||||
'''
|
||||
@abstractmethod
|
||||
def to_polygons(self,
|
||||
num_vertices: Optional[int] = None,
|
||||
max_arclen: Optional[float] = None,
|
||||
) -> List['Polygon']:
|
||||
def to_polygons(
|
||||
self,
|
||||
num_vertices: Optional[int] = None,
|
||||
max_arclen: Optional[float] = None,
|
||||
) -> List['Polygon']:
|
||||
"""
|
||||
Returns a list of polygons which approximate the shape.
|
||||
|
||||
|
|
@ -93,10 +94,11 @@ class Shape(PositionableImpl, LayerableImpl, DoseableImpl, Rotatable, Mirrorable
|
|||
'''
|
||||
---- Non-abstract methods
|
||||
'''
|
||||
def manhattanize_fast(self,
|
||||
grid_x: ArrayLike,
|
||||
grid_y: ArrayLike,
|
||||
) -> List['Polygon']:
|
||||
def manhattanize_fast(
|
||||
self,
|
||||
grid_x: ArrayLike,
|
||||
grid_y: ArrayLike,
|
||||
) -> List['Polygon']:
|
||||
"""
|
||||
Returns a list of polygons with grid-aligned ("Manhattan") edges approximating the shape.
|
||||
|
||||
|
|
@ -200,10 +202,11 @@ class Shape(PositionableImpl, LayerableImpl, DoseableImpl, Rotatable, Mirrorable
|
|||
|
||||
return manhattan_polygons
|
||||
|
||||
def manhattanize(self,
|
||||
grid_x: ArrayLike,
|
||||
grid_y: ArrayLike,
|
||||
) -> List['Polygon']:
|
||||
def manhattanize(
|
||||
self,
|
||||
grid_x: ArrayLike,
|
||||
grid_y: ArrayLike,
|
||||
) -> List['Polygon']:
|
||||
"""
|
||||
Returns a list of polygons with grid-aligned ("Manhattan") edges approximating the shape.
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class Text(RotatableImpl, Shape, metaclass=AutoSlots):
|
|||
return self._string
|
||||
|
||||
@string.setter
|
||||
def string(self, val: str):
|
||||
def string(self, val: str) -> None:
|
||||
self._string = val
|
||||
|
||||
# Height property
|
||||
|
|
@ -44,7 +44,7 @@ class Text(RotatableImpl, Shape, metaclass=AutoSlots):
|
|||
return self._height
|
||||
|
||||
@height.setter
|
||||
def height(self, val: float):
|
||||
def height(self, val: float) -> None:
|
||||
if not is_scalar(val):
|
||||
raise PatternError('Height must be a scalar')
|
||||
self._height = val
|
||||
|
|
@ -55,26 +55,27 @@ class Text(RotatableImpl, Shape, metaclass=AutoSlots):
|
|||
return self._mirrored
|
||||
|
||||
@mirrored.setter
|
||||
def mirrored(self, val: Sequence[bool]):
|
||||
def mirrored(self, val: Sequence[bool]) -> None:
|
||||
if is_scalar(val):
|
||||
raise PatternError('Mirrored must be a 2-element list of booleans')
|
||||
self._mirrored = numpy.array(val, dtype=bool, copy=True)
|
||||
|
||||
def __init__(self,
|
||||
string: str,
|
||||
height: float,
|
||||
font_path: str,
|
||||
*,
|
||||
offset: vector2 = (0.0, 0.0),
|
||||
rotation: float = 0.0,
|
||||
mirrored: Tuple[bool, bool] = (False, False),
|
||||
layer: layer_t = 0,
|
||||
dose: float = 1.0,
|
||||
repetition: Optional[Repetition] = None,
|
||||
annotations: Optional[annotations_t] = None,
|
||||
locked: bool = False,
|
||||
raw: bool = False,
|
||||
):
|
||||
def __init__(
|
||||
self,
|
||||
string: str,
|
||||
height: float,
|
||||
font_path: str,
|
||||
*,
|
||||
offset: vector2 = (0.0, 0.0),
|
||||
rotation: float = 0.0,
|
||||
mirrored: Tuple[bool, bool] = (False, False),
|
||||
layer: layer_t = 0,
|
||||
dose: float = 1.0,
|
||||
repetition: Optional[Repetition] = None,
|
||||
annotations: Optional[annotations_t] = None,
|
||||
locked: bool = False,
|
||||
raw: bool = False,
|
||||
) -> None:
|
||||
LockableImpl.unlock(self)
|
||||
self.identifier = ()
|
||||
if raw:
|
||||
|
|
@ -109,10 +110,11 @@ class Text(RotatableImpl, Shape, metaclass=AutoSlots):
|
|||
new.set_locked(self.locked)
|
||||
return new
|
||||
|
||||
def to_polygons(self,
|
||||
poly_num_points: Optional[int] = None, # unused
|
||||
poly_max_arclen: Optional[float] = None, # unused
|
||||
) -> List[Polygon]:
|
||||
def to_polygons(
|
||||
self,
|
||||
poly_num_points: Optional[int] = None, # unused
|
||||
poly_max_arclen: Optional[float] = None, # unused
|
||||
) -> List[Polygon]:
|
||||
all_polygons = []
|
||||
total_advance = 0.0
|
||||
for char in self.string:
|
||||
|
|
@ -166,10 +168,11 @@ class Text(RotatableImpl, Shape, metaclass=AutoSlots):
|
|||
return bounds
|
||||
|
||||
|
||||
def get_char_as_polygons(font_path: str,
|
||||
char: str,
|
||||
resolution: float = 48 * 64,
|
||||
) -> Tuple[List[List[List[float]]], float]:
|
||||
def get_char_as_polygons(
|
||||
font_path: str,
|
||||
char: str,
|
||||
resolution: float = 48 * 64,
|
||||
) -> Tuple[List[List[List[float]]], float]:
|
||||
from freetype import Face # type: ignore
|
||||
from matplotlib.path import Path # type: ignore
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue