Click or drag to resize

GeometryOffsetPolygon2d Method

Inflates or deflates polygon by delta units (pixels). If delta is positive, makes the polygon grow outward. If delta is negative, shrinks the polygon inward. Returns an array of polygons because inflating/deflating may result in multiple discrete polygons. Returns an empty array if delta is negative and the absolute value of it approximately exceeds the minimum bounding rectangle dimensions of the polygon.

Each polygon's vertices will be rounded as determined by join_type, see GeometryPolyJoinType.

The operation may result in an outer polygon (boundary) and inner polygon (hole) produced which could be distinguished by calling IsPolygonClockwise(Vector2).

Note: To translate the polygon's vertices specifically, use the Transform2D.xform method:

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)]

Namespace:  Godot
Assembly:  GodotSharp (in GodotSharp.dll) Version: 1.0.0
Syntax
C#
public static Array OffsetPolygon2d(
	Vector2[] polygon,
	float delta,
	GeometryPolyJoinType joinType = GeometryPolyJoinType.Square
)

Parameters

polygon
Type: GodotVector2

[Missing <param name="polygon"/> documentation for "M:Godot.Geometry.OffsetPolygon2d(Godot.Vector2[],System.Single,Godot.Geometry.PolyJoinType)"]

delta
Type: SystemSingle

[Missing <param name="delta"/> documentation for "M:Godot.Geometry.OffsetPolygon2d(Godot.Vector2[],System.Single,Godot.Geometry.PolyJoinType)"]

joinType (Optional)
Type: GodotGeometryPolyJoinType

[Missing <param name="joinType"/> documentation for "M:Godot.Geometry.OffsetPolygon2d(Godot.Vector2[],System.Single,Godot.Geometry.PolyJoinType)"]

Return Value

Type: Array

[Missing <returns> documentation for "M:Godot.Geometry.OffsetPolygon2d(Godot.Vector2[],System.Single,Godot.Geometry.PolyJoinType)"]

See Also