heitzmann / gdstk

Gdstk (GDSII Tool Kit) is a C++/Python library for creation and manipulation of GDSII and OASIS files.
https://heitzmann.github.io/gdstk/
Boost Software License 1.0
324 stars 78 forks source link

How to change the size of Polygon with points? #226

Open EnesBae opened 6 months ago

EnesBae commented 6 months ago

Is there any way to adjust the size of Polygon with points?

For example, +1 (up) -1 (down) in the y direction [[1,1], [2,1], [2,3], [1,3]] → [[1,0], [2,0], [2,4], [1,4]]

It is complicated to apply it to various cases as a "scale" method, so I want to change it using numbers, but it is impossible to change it because the points attribute is read-only.

Thank you for your help.

heitzmann commented 6 months ago

There are several transformation methods you can use to change the polygon coordinates: scale, rotate, mirror, transform, translate - https://heitzmann.github.io/gdstk/geometry/gdstk.Polygon.html

If you need something even more general that those transforms, you'll have to create a new polygon and replace the old one.