From 853872f0e28aaac9fda395fccc167fbb72307ffc Mon Sep 17 00:00:00 2001 From: Uri Shaked Date: Sun, 7 Dec 2025 20:49:39 +0200 Subject: [PATCH] perf(tech/gf180mcuD): optimize corner logo GDS files Generate optimized polygons instead of generating a rect for each pixel from the source PNG image. --- tech/gf180mcuD/logo/generate_logos.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/tech/gf180mcuD/logo/generate_logos.py b/tech/gf180mcuD/logo/generate_logos.py index 675e9ab..427e4d3 100644 --- a/tech/gf180mcuD/logo/generate_logos.py +++ b/tech/gf180mcuD/logo/generate_logos.py @@ -67,18 +67,27 @@ class LogoGenerator: cell.add(boundary) img = self.img + pixels = [] for y in range(img.height): for x in range(img.width): color: int = img.getpixel((x, y)) # type: ignore if color < 16: flipped_y = img.height - y - 1 # flip vertically - rect = gdstk.rectangle( - (x * self.pixel_size, flipped_y * self.pixel_size), - ((x + 1) * self.pixel_size, (flipped_y + 1) * self.pixel_size), - layer=LOGO_LAYER[0], - datatype=LOGO_LAYER[1], - ) - cell.add(rect) + x1 = x * self.pixel_size + y1 = flipped_y * self.pixel_size + x2 = (x + 1) * self.pixel_size + y2 = (flipped_y + 1) * self.pixel_size + pixels += [gdstk.Polygon([(x1, y1), (x2, y1), (x2, y2), (x1, y2)])] + + cell.add( + *gdstk.offset( + pixels, + 0, + use_union=True, + layer=LOGO_LAYER[0], + datatype=LOGO_LAYER[1], + ) + ) if self.variant == "tr": nofill_poly = gdstk.Polygon(