Set standard constructor arg order and add rotation
and mirrored
args where reasonable
This commit is contained in:
parent
8dfb6d4440
commit
c6fac19fe0
@ -1,4 +1,4 @@
|
|||||||
from typing import List
|
from typing import List, Tuple
|
||||||
import math
|
import math
|
||||||
import numpy
|
import numpy
|
||||||
from numpy import pi
|
from numpy import pi
|
||||||
@ -141,19 +141,21 @@ class Arc(Shape):
|
|||||||
radii: vector2,
|
radii: vector2,
|
||||||
angles: vector2,
|
angles: vector2,
|
||||||
width: float,
|
width: float,
|
||||||
rotation: float=0,
|
|
||||||
poly_num_points: int=DEFAULT_POLY_NUM_POINTS,
|
poly_num_points: int=DEFAULT_POLY_NUM_POINTS,
|
||||||
poly_max_arclen: float=None,
|
poly_max_arclen: float=None,
|
||||||
offset: vector2=(0.0, 0.0),
|
offset: vector2=(0.0, 0.0),
|
||||||
|
rotation: float=0,
|
||||||
|
mirrored: Tuple[bool] = (False, False),
|
||||||
layer: int=0,
|
layer: int=0,
|
||||||
dose: float=1.0):
|
dose: float=1.0):
|
||||||
self.offset = offset
|
|
||||||
self.layer = layer
|
|
||||||
self.dose = dose
|
|
||||||
self.radii = radii
|
self.radii = radii
|
||||||
self.angles = angles
|
self.angles = angles
|
||||||
self.width = width
|
self.width = width
|
||||||
|
self.offset = offset
|
||||||
self.rotation = rotation
|
self.rotation = rotation
|
||||||
|
[self.mirror(a) for a, do in enumerate(mirrored) if do]
|
||||||
|
self.layer = layer
|
||||||
|
self.dose = dose
|
||||||
self.poly_num_points = poly_num_points
|
self.poly_num_points = poly_num_points
|
||||||
self.poly_max_arclen = poly_max_arclen
|
self.poly_max_arclen = poly_max_arclen
|
||||||
|
|
||||||
@ -201,8 +203,7 @@ class Arc(Shape):
|
|||||||
ys = numpy.hstack((ys1, ys2))
|
ys = numpy.hstack((ys1, ys2))
|
||||||
xys = numpy.vstack((xs, ys)).T
|
xys = numpy.vstack((xs, ys)).T
|
||||||
|
|
||||||
poly = Polygon(xys, dose=self.dose, layer=self.layer, offset=self.offset)
|
poly = Polygon(xys, dose=self.dose, layer=self.layer, offset=self.offset, rotation=self.rotation)
|
||||||
poly.rotate(self.rotation)
|
|
||||||
return [poly]
|
return [poly]
|
||||||
|
|
||||||
def get_bounds(self) -> numpy.ndarray:
|
def get_bounds(self) -> numpy.ndarray:
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from typing import List
|
from typing import List, Tuple
|
||||||
import math
|
import math
|
||||||
import numpy
|
import numpy
|
||||||
from numpy import pi
|
from numpy import pi
|
||||||
@ -82,17 +82,19 @@ class Ellipse(Shape):
|
|||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
radii: vector2,
|
radii: vector2,
|
||||||
rotation: float=0,
|
|
||||||
poly_num_points: int=DEFAULT_POLY_NUM_POINTS,
|
poly_num_points: int=DEFAULT_POLY_NUM_POINTS,
|
||||||
poly_max_arclen: float=None,
|
poly_max_arclen: float=None,
|
||||||
offset: vector2=(0.0, 0.0),
|
offset: vector2=(0.0, 0.0),
|
||||||
|
rotation: float=0,
|
||||||
|
mirrored: Tuple[bool] = (False, False),
|
||||||
layer: int=0,
|
layer: int=0,
|
||||||
dose: float=1.0):
|
dose: float=1.0):
|
||||||
|
self.radii = radii
|
||||||
self.offset = offset
|
self.offset = offset
|
||||||
|
self.rotation = rotation
|
||||||
|
[self.mirror(a) for a, do in enumerate(mirrored) if do]
|
||||||
self.layer = layer
|
self.layer = layer
|
||||||
self.dose = dose
|
self.dose = dose
|
||||||
self.radii = radii
|
|
||||||
self.rotation = rotation
|
|
||||||
self.poly_num_points = poly_num_points
|
self.poly_num_points = poly_num_points
|
||||||
self.poly_max_arclen = poly_max_arclen
|
self.poly_max_arclen = poly_max_arclen
|
||||||
|
|
||||||
@ -129,8 +131,7 @@ class Ellipse(Shape):
|
|||||||
ys = r1 * sin_th
|
ys = r1 * sin_th
|
||||||
xys = numpy.vstack((xs, ys)).T
|
xys = numpy.vstack((xs, ys)).T
|
||||||
|
|
||||||
poly = Polygon(xys, dose=self.dose, layer=self.layer, offset=self.offset)
|
poly = Polygon(xys, dose=self.dose, layer=self.layer, offset=self.offset, rotation=self.rotation)
|
||||||
poly.rotate(self.rotation)
|
|
||||||
return [poly]
|
return [poly]
|
||||||
|
|
||||||
def get_bounds(self) -> numpy.ndarray:
|
def get_bounds(self) -> numpy.ndarray:
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from typing import List
|
from typing import List, Tuple
|
||||||
import copy
|
import copy
|
||||||
import numpy
|
import numpy
|
||||||
from numpy import pi
|
from numpy import pi
|
||||||
@ -71,12 +71,17 @@ class Polygon(Shape):
|
|||||||
def __init__(self,
|
def __init__(self,
|
||||||
vertices: numpy.ndarray,
|
vertices: numpy.ndarray,
|
||||||
offset: vector2=(0.0, 0.0),
|
offset: vector2=(0.0, 0.0),
|
||||||
|
rotation: float=0.0,
|
||||||
|
mirrored: Tuple[bool] = (False, False),
|
||||||
layer: int=0,
|
layer: int=0,
|
||||||
dose: float=1.0):
|
dose: float=1.0,
|
||||||
self.offset = offset
|
):
|
||||||
self.layer = layer
|
self.layer = layer
|
||||||
self.dose = dose
|
self.dose = dose
|
||||||
self.vertices = vertices
|
self.vertices = vertices
|
||||||
|
self.offset = offset
|
||||||
|
self.rotate(rotation)
|
||||||
|
[self.mirror(a) for a, do in enumerate(mirrored) if do]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def square(side_length: float,
|
def square(side_length: float,
|
||||||
|
@ -61,15 +61,15 @@ class Text(Shape):
|
|||||||
def mirrored(self, val: List[bool]):
|
def mirrored(self, val: List[bool]):
|
||||||
if is_scalar(val):
|
if is_scalar(val):
|
||||||
raise PatternError('Mirrored must be a 2-element list of booleans')
|
raise PatternError('Mirrored must be a 2-element list of booleans')
|
||||||
self._mirrored = val
|
self._mirrored = list(val)
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
string: str,
|
string: str,
|
||||||
height: float,
|
height: float,
|
||||||
font_path: str,
|
font_path: str,
|
||||||
mirrored: List[bool]=None,
|
|
||||||
rotation: float=0.0,
|
|
||||||
offset: vector2=(0.0, 0.0),
|
offset: vector2=(0.0, 0.0),
|
||||||
|
rotation: float=0.0,
|
||||||
|
mirrored: Tuple[bool]=(False, False),
|
||||||
layer: int=0,
|
layer: int=0,
|
||||||
dose: float=1.0):
|
dose: float=1.0):
|
||||||
self.offset = offset
|
self.offset = offset
|
||||||
@ -79,8 +79,6 @@ class Text(Shape):
|
|||||||
self.height = height
|
self.height = height
|
||||||
self.rotation = rotation
|
self.rotation = rotation
|
||||||
self.font_path = font_path
|
self.font_path = font_path
|
||||||
if mirrored is None:
|
|
||||||
mirrored = [False, False]
|
|
||||||
self.mirrored = mirrored
|
self.mirrored = mirrored
|
||||||
|
|
||||||
def to_polygons(self,
|
def to_polygons(self,
|
||||||
|
Loading…
Reference in New Issue
Block a user