Polygon2D

package
v0.0.0-...-357ca8a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 20, 2025 License: MIT Imports: 29 Imported by: 0

Documentation

Overview

A Polygon2D is defined by a set of points. Each point is connected to the next, with the final point being connected to the first, resulting in a closed polygon. Polygon2Ds can be filled with color (solid or gradient) or filled with a given texture.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Advanced

type Advanced = class

Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.

type Any

type Any interface {
	gd.IsClass
	AsPolygon2D() Instance
}

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension

func (*Extension[T]) AsCanvasItem

func (self *Extension[T]) AsCanvasItem() CanvasItem.Instance

func (*Extension[T]) AsNode

func (self *Extension[T]) AsNode() Node.Instance

func (*Extension[T]) AsNode2D

func (self *Extension[T]) AsNode2D() Node2D.Instance

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

func (*Extension[T]) AsPolygon2D

func (self *Extension[T]) AsPolygon2D() Instance

type ID

type ID Object.ID

ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Instance

type Instance [1]gdclass.Polygon2D

Instance of the class with convieniently typed arguments and results.

var Nil Instance

Nil is a nil/null instance of the class. Equivalent to the zero value.

func New

func New() Instance

func (Instance) AddBone

func (self Instance) AddBone(path string, weights []float32)

Adds a bone with the specified 'path' and 'weights'.

func (Instance) Antialiased

func (self Instance) Antialiased() bool

If true, polygon edges will be anti-aliased.

func (Instance) AsCanvasItem

func (self Instance) AsCanvasItem() CanvasItem.Instance

func (Instance) AsNode

func (self Instance) AsNode() Node.Instance

func (Instance) AsNode2D

func (self Instance) AsNode2D() Node2D.Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AsPolygon2D

func (self Instance) AsPolygon2D() Instance

func (Instance) ClearBones

func (self Instance) ClearBones()

Removes all bones from this Polygon2D.

func (Instance) Color

func (self Instance) Color() Color.RGBA

The polygon's fill color. If Texture is set, it will be multiplied by this color. It will also be the default color for vertices not set in VertexColors.

func (Instance) EraseBone

func (self Instance) EraseBone(index int)

Removes the specified bone from this Polygon2D.

func (Instance) GetBoneCount

func (self Instance) GetBoneCount() int

Returns the number of bones in this Polygon2D.

func (Instance) GetBonePath

func (self Instance) GetBonePath(index int) string

Returns the path to the node associated with the specified bone.

func (Instance) GetBoneWeights

func (self Instance) GetBoneWeights(index int) []float32

Returns the weight values of the specified bone.

func (Instance) ID

func (self Instance) ID() ID

func (Instance) InternalVertexCount

func (self Instance) InternalVertexCount() int

Number of internal vertices, used for UV mapping.

func (Instance) InvertBorder

func (self Instance) InvertBorder() Float.X

Added padding applied to the bounding box when InvertEnabled is set to true. Setting this value too small may result in a "Bad Polygon" error.

func (Instance) InvertEnabled

func (self Instance) InvertEnabled() bool

If true, the polygon will be inverted, containing the area outside the defined points and extending to the InvertBorder.

func (Instance) Offset

func (self Instance) Offset() Vector2.XY

The offset applied to each vertex.

func (Instance) Polygon

func (self Instance) Polygon() []Vector2.XY

The polygon's list of vertices. The final point will be connected to the first.

func (Instance) Polygons

func (self Instance) Polygons() [][]int32

The list of polygons, in case more than one is being represented. Every individual polygon is stored as a []int32 where each int is an index to a point in Polygon. If empty, this property will be ignored, and the resulting single polygon will be composed of all points in Polygon, using the order they are stored in.

func (Instance) SetAntialiased

func (self Instance) SetAntialiased(value bool)

SetAntialiased sets the property returned by [GetAntialiased].

func (Instance) SetBonePath

func (self Instance) SetBonePath(index int, path string)

Sets the path to the node associated with the specified bone.

func (Instance) SetBoneWeights

func (self Instance) SetBoneWeights(index int, weights []float32)

Sets the weight values for the specified bone.

func (Instance) SetColor

func (self Instance) SetColor(value Color.RGBA)

SetColor sets the property returned by [GetColor].

func (Instance) SetInternalVertexCount

func (self Instance) SetInternalVertexCount(value int)

SetInternalVertexCount sets the property returned by [GetInternalVertexCount].

func (Instance) SetInvertBorder

func (self Instance) SetInvertBorder(value Float.X)

SetInvertBorder sets the property returned by [GetInvertBorder].

func (Instance) SetInvertEnabled

func (self Instance) SetInvertEnabled(value bool)

SetInvertEnabled sets the property returned by [GetInvertEnabled].

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) SetOffset

func (self Instance) SetOffset(value Vector2.XY)

SetOffset sets the property returned by [GetOffset].

func (Instance) SetPolygon

func (self Instance) SetPolygon(value []Vector2.XY)

SetPolygon sets the property returned by [GetPolygon].

func (Instance) SetPolygons

func (self Instance) SetPolygons(value [][]int32)

SetPolygons sets the property returned by [GetPolygons].

func (Instance) SetSkeleton

func (self Instance) SetSkeleton(value string)

SetSkeleton sets the property returned by [GetSkeleton].

func (Instance) SetTexture

func (self Instance) SetTexture(value Texture2D.Instance)

SetTexture sets the property returned by [GetTexture].

func (Instance) SetTextureOffset

func (self Instance) SetTextureOffset(value Vector2.XY)

SetTextureOffset sets the property returned by [GetTextureOffset].

func (Instance) SetTextureRotation

func (self Instance) SetTextureRotation(value Angle.Radians)

SetTextureRotation sets the property returned by [GetTextureRotation].

func (Instance) SetTextureScale

func (self Instance) SetTextureScale(value Vector2.XY)

SetTextureScale sets the property returned by [GetTextureScale].

func (Instance) SetUv

func (self Instance) SetUv(value []Vector2.XY)

SetUv sets the property returned by [GetUv].

func (Instance) SetVertexColors

func (self Instance) SetVertexColors(value []Color.RGBA)

SetVertexColors sets the property returned by [GetVertexColors].

func (Instance) Skeleton

func (self Instance) Skeleton() string

Path to a Skeleton2D node used for skeleton-based deformations of this polygon. If empty or invalid, skeletal deformations will not be used.

func (Instance) Texture

func (self Instance) Texture() Texture2D.Instance

The polygon's fill texture. Use Uv to set texture coordinates.

func (Instance) TextureOffset

func (self Instance) TextureOffset() Vector2.XY

Amount to offset the polygon's Texture. If set to Vector2(0, 0), the texture's origin (its top-left corner) will be placed at the polygon's position.

func (Instance) TextureRotation

func (self Instance) TextureRotation() Angle.Radians

The texture's rotation in radians.

func (Instance) TextureScale

func (self Instance) TextureScale() Vector2.XY

Amount to multiply the Uv coordinates when using Texture. Larger values make the texture smaller, and vice versa.

func (Instance) Uv

func (self Instance) Uv() []Vector2.XY

Texture coordinates for each vertex of the polygon. There should be one UV value per polygon vertex. If there are fewer, undefined vertices will use Vector2(0, 0).

func (Instance) VertexColors

func (self Instance) VertexColors() []Color.RGBA

Color for each vertex. Colors are interpolated between vertices, resulting in smooth gradients. There should be one per polygon vertex. If there are fewer, undefined vertices will use Color.

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL