From 28424be3db4df4eb67ed95523eec2925d0dce0ae Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Thu, 23 Feb 2023 13:42:26 -0800 Subject: [PATCH] add polygon() and label() convenience methods --- masque/pattern.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/masque/pattern.py b/masque/pattern.py index e69a66a..9e3afa1 100644 --- a/masque/pattern.py +++ b/masque/pattern.py @@ -540,6 +540,21 @@ class Pattern(PortList, AnnotatableImpl, Mirrorable): self.refs.append(Ref(*args, **kwargs)) return self + def polygon(self, *args: Any, **kwargs: Any) -> Self: + """ + Convenience function which constructs a `Polygon` object and adds it + to this pattern. + + Args: + *args: Passed to `Polygon()` + **kwargs: Passed to `Polygon()` + + Returns: + self + """ + self.shapes.append(Polygon(*args, **kwargs)) + return self + def rect(self, *args: Any, **kwargs: Any) -> Self: """ Convenience function which calls `Polygon.rect` to construct a @@ -555,6 +570,22 @@ class Pattern(PortList, AnnotatableImpl, Mirrorable): self.shapes.append(Polygon.rect(*args, **kwargs)) return self + def label(self, *args: Any, **kwargs: Any) -> Self: + """ + Convenience function which constructs a `Label` object + and adds it to this pattern. + + Args: + *args: Passed to `Label()` + **kwargs: Passed to `Label()` + + Returns: + self + """ + self.labels.append(Label(*args, **kwargs)) + return self + + def flatten( self, library: Mapping[str, 'Pattern'],