is there a function that offsets a 2d polygon/Poolvector2D? why doesn't Geometry.offset_polygon2d() do so?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By AriWD40

I have been using Godot engine for a year now, and I have often thought it is incompetent, and faulty.

Every single time, I have discovered that the engine is perfectly fine, and I have only myself to blame.

Except for now, this is my very first and only grievance. It is deeply incompetent, so I’ve filed an issue:

:bust_in_silhouette: Reply From: SanderVanhove

Geometry.offset_polygon2d() inflates the shape, kinda confusing.

But what you want is a Transform2D. For example if you want to offset the polygon by 50px in the x and y direction you do something like this:

var polygon = PoolVector2Array([Vector2(0, 0), Vector2(100, 0), Vector2(100, 100), Vector2(0, 100)])

var offset = Vector2(50, 50)
polygon = Transform2D(0, offset).xform(polygon)

print(polygon) # prints [Vector2(50, 50), Vector2(150, 50), Vector2(150, 150), Vector2(50, 150)]