From 1eac3baf6a83962bf70d69bd8024071fa6d8447a Mon Sep 17 00:00:00 2001 From: jan Date: Tue, 15 Apr 2025 17:21:49 -0700 Subject: [PATCH] [pattern] add arg to , useful for whole-library scaling --- masque/pattern.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/masque/pattern.py b/masque/pattern.py index 0ae230d..afd73fc 100644 --- a/masque/pattern.py +++ b/masque/pattern.py @@ -648,21 +648,25 @@ class Pattern(PortList, AnnotatableImpl, Mirrorable): cast(Scalable, entry).scale_by(c) return self - def scale_by(self, c: float) -> Self: + def scale_by(self, c: float, scale_refs: bool = True) -> Self: """ Scale this Pattern by the given value - (all shapes and refs and their offsets are scaled, - as are all label and port offsets) + All shapes and (optionally) refs and their offsets are scaled, + as are all label and port offsets. Args: c: factor to scale by + scale_refs: Whether to scale refs. Ref offsets are always scaled, + but it may be desirable to not scale the ref itself (e.g. if + the target cell was also scaled). Returns: self """ for entry in chain_elements(self.shapes, self.refs): cast(Positionable, entry).offset *= c - cast(Scalable, entry).scale_by(c) + if scale_refs or not isinstance(entry, Ref): + cast(Scalable, entry).scale_by(c) rep = cast(Repeatable, entry).repetition if rep: