From c6fac19fe0050213c409385e93a2db862ee8d0e7 Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Sat, 20 Apr 2019 14:18:25 -0700 Subject: [PATCH] Set standard constructor arg order and add `rotation` and `mirrored` args where reasonable --- masque/shapes/arc.py | 15 ++++++++------- masque/shapes/ellipse.py | 13 +++++++------ masque/shapes/polygon.py | 11 ++++++++--- masque/shapes/text.py | 8 +++----- 4 files changed, 26 insertions(+), 21 deletions(-) diff --git a/masque/shapes/arc.py b/masque/shapes/arc.py index 74f0ec0..c468564 100644 --- a/masque/shapes/arc.py +++ b/masque/shapes/arc.py @@ -1,4 +1,4 @@ -from typing import List +from typing import List, Tuple import math import numpy from numpy import pi @@ -141,19 +141,21 @@ class Arc(Shape): radii: vector2, angles: vector2, width: float, - rotation: float=0, poly_num_points: int=DEFAULT_POLY_NUM_POINTS, poly_max_arclen: float=None, offset: vector2=(0.0, 0.0), + rotation: float=0, + mirrored: Tuple[bool] = (False, False), layer: int=0, dose: float=1.0): - self.offset = offset - self.layer = layer - self.dose = dose self.radii = radii self.angles = angles self.width = width + self.offset = offset 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_max_arclen = poly_max_arclen @@ -201,8 +203,7 @@ class Arc(Shape): ys = numpy.hstack((ys1, ys2)) xys = numpy.vstack((xs, ys)).T - poly = Polygon(xys, dose=self.dose, layer=self.layer, offset=self.offset) - poly.rotate(self.rotation) + poly = Polygon(xys, dose=self.dose, layer=self.layer, offset=self.offset, rotation=self.rotation) return [poly] def get_bounds(self) -> numpy.ndarray: diff --git a/masque/shapes/ellipse.py b/masque/shapes/ellipse.py index 6b7317f..724c11d 100644 --- a/masque/shapes/ellipse.py +++ b/masque/shapes/ellipse.py @@ -1,4 +1,4 @@ -from typing import List +from typing import List, Tuple import math import numpy from numpy import pi @@ -82,17 +82,19 @@ class Ellipse(Shape): def __init__(self, radii: vector2, - rotation: float=0, poly_num_points: int=DEFAULT_POLY_NUM_POINTS, poly_max_arclen: float=None, offset: vector2=(0.0, 0.0), + rotation: float=0, + mirrored: Tuple[bool] = (False, False), layer: int=0, dose: float=1.0): + self.radii = radii self.offset = offset + self.rotation = rotation + [self.mirror(a) for a, do in enumerate(mirrored) if do] self.layer = layer self.dose = dose - self.radii = radii - self.rotation = rotation self.poly_num_points = poly_num_points self.poly_max_arclen = poly_max_arclen @@ -129,8 +131,7 @@ class Ellipse(Shape): ys = r1 * sin_th xys = numpy.vstack((xs, ys)).T - poly = Polygon(xys, dose=self.dose, layer=self.layer, offset=self.offset) - poly.rotate(self.rotation) + poly = Polygon(xys, dose=self.dose, layer=self.layer, offset=self.offset, rotation=self.rotation) return [poly] def get_bounds(self) -> numpy.ndarray: diff --git a/masque/shapes/polygon.py b/masque/shapes/polygon.py index a0b214b..0f97e89 100644 --- a/masque/shapes/polygon.py +++ b/masque/shapes/polygon.py @@ -1,4 +1,4 @@ -from typing import List +from typing import List, Tuple import copy import numpy from numpy import pi @@ -71,12 +71,17 @@ class Polygon(Shape): def __init__(self, vertices: numpy.ndarray, offset: vector2=(0.0, 0.0), + rotation: float=0.0, + mirrored: Tuple[bool] = (False, False), layer: int=0, - dose: float=1.0): - self.offset = offset + dose: float=1.0, + ): self.layer = layer self.dose = dose self.vertices = vertices + self.offset = offset + self.rotate(rotation) + [self.mirror(a) for a, do in enumerate(mirrored) if do] @staticmethod def square(side_length: float, diff --git a/masque/shapes/text.py b/masque/shapes/text.py index 64b7468..167e2c2 100644 --- a/masque/shapes/text.py +++ b/masque/shapes/text.py @@ -61,15 +61,15 @@ class Text(Shape): def mirrored(self, val: List[bool]): if is_scalar(val): raise PatternError('Mirrored must be a 2-element list of booleans') - self._mirrored = val + self._mirrored = list(val) def __init__(self, string: str, height: float, font_path: str, - mirrored: List[bool]=None, - rotation: float=0.0, offset: vector2=(0.0, 0.0), + rotation: float=0.0, + mirrored: Tuple[bool]=(False, False), layer: int=0, dose: float=1.0): self.offset = offset @@ -79,8 +79,6 @@ class Text(Shape): self.height = height self.rotation = rotation self.font_path = font_path - if mirrored is None: - mirrored = [False, False] self.mirrored = mirrored def to_polygons(self,