perf(tech/gf180mcuD): optimize corner logo GDS files

Generate optimized polygons instead of generating a rect for each pixel from the source PNG image.
This commit is contained in:
Uri Shaked
2025-12-07 20:49:39 +02:00
parent 9552777451
commit 853872f0e2
+13 -4
View File
@@ -67,18 +67,27 @@ class LogoGenerator:
cell.add(boundary) cell.add(boundary)
img = self.img img = self.img
pixels = []
for y in range(img.height): for y in range(img.height):
for x in range(img.width): for x in range(img.width):
color: int = img.getpixel((x, y)) # type: ignore color: int = img.getpixel((x, y)) # type: ignore
if color < 16: if color < 16:
flipped_y = img.height - y - 1 # flip vertically flipped_y = img.height - y - 1 # flip vertically
rect = gdstk.rectangle( x1 = x * self.pixel_size
(x * self.pixel_size, flipped_y * self.pixel_size), y1 = flipped_y * self.pixel_size
((x + 1) * self.pixel_size, (flipped_y + 1) * 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], layer=LOGO_LAYER[0],
datatype=LOGO_LAYER[1], datatype=LOGO_LAYER[1],
) )
cell.add(rect) )
if self.variant == "tr": if self.variant == "tr":
nofill_poly = gdstk.Polygon( nofill_poly = gdstk.Polygon(