Line2D

package
v0.0.0-...-535787f Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2025 License: MIT Imports: 30 Imported by: 0

Documentation

Overview

This node draws a 2D polyline, i.e. a shape consisting of several points connected by segments. graphics.gd/classdb/Line2D is not a mathematical polyline, i.e. the segments are not infinitely thin. It is intended for rendering and it can be colored and optionally textured.

Warning: Certain configurations may be impossible to draw nicely, such as very sharp angles. In these situations, the node uses fallback drawing logic to look decent.

Note: graphics.gd/classdb/Line2D is drawn using a 2D mesh.

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
	AsLine2D() Instance
}

type Expanded

type Expanded [1]gdclass.Line2D

func (Expanded) AddPoint

func (self Expanded) AddPoint(position Vector2.XY, index int)

Adds a point with the specified 'position' relative to the polyline's own position. If no 'index' is provided, the new point will be added to the end of the points array.

If 'index' is given, the new point is inserted before the existing point identified by index 'index'. The indices of the points after the new point get increased by 1. The provided 'index' must not exceed the number of existing points in the polyline. See Instance.GetPointCount.

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

func (self *Extension[T]) AsLine2D() 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

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.Line2D

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

func (self Instance) AddPoint(position Vector2.XY)

Adds a point with the specified 'position' relative to the polyline's own position. If no 'index' is provided, the new point will be added to the end of the points array.

If 'index' is given, the new point is inserted before the existing point identified by index 'index'. The indices of the points after the new point get increased by 1. The provided 'index' must not exceed the number of existing points in the polyline. See Instance.GetPointCount.

func (Instance) Antialiased

func (self Instance) Antialiased() bool

func (Instance) AsCanvasItem

func (self Instance) AsCanvasItem() CanvasItem.Instance

func (Instance) AsLine2D

func (self Instance) AsLine2D() 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) BeginCapMode

func (self Instance) BeginCapMode() LineCapMode

func (Instance) ClearPoints

func (self Instance) ClearPoints()

Removes all points from the polyline, making it empty.

func (Instance) Closed

func (self Instance) Closed() bool

func (Instance) DefaultColor

func (self Instance) DefaultColor() Color.RGBA

func (Instance) EndCapMode

func (self Instance) EndCapMode() LineCapMode

func (Instance) GetPointCount

func (self Instance) GetPointCount() int

Returns the number of points in the polyline.

func (Instance) GetPointPosition

func (self Instance) GetPointPosition(index int) Vector2.XY

Returns the position of the point at index 'index'.

func (Instance) Gradient

func (self Instance) Gradient() Gradient.Instance

func (Instance) ID

func (self Instance) ID() ID

func (Instance) JointMode

func (self Instance) JointMode() LineJointMode

func (Instance) Points

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

func (Instance) RemovePoint

func (self Instance) RemovePoint(index int)

Removes the point at index 'index' from the polyline.

func (Instance) RoundPrecision

func (self Instance) RoundPrecision() int

func (Instance) SetAntialiased

func (self Instance) SetAntialiased(value bool)

func (Instance) SetBeginCapMode

func (self Instance) SetBeginCapMode(value LineCapMode)

func (Instance) SetClosed

func (self Instance) SetClosed(value bool)

func (Instance) SetDefaultColor

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

func (Instance) SetEndCapMode

func (self Instance) SetEndCapMode(value LineCapMode)

func (Instance) SetGradient

func (self Instance) SetGradient(value Gradient.Instance)

func (Instance) SetJointMode

func (self Instance) SetJointMode(value LineJointMode)

func (*Instance) SetObject

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

func (Instance) SetPointPosition

func (self Instance) SetPointPosition(index int, position Vector2.XY)

Overwrites the position of the point at the given 'index' with the supplied 'position'.

func (Instance) SetPoints

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

func (Instance) SetRoundPrecision

func (self Instance) SetRoundPrecision(value int)

func (Instance) SetSharpLimit

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

func (Instance) SetTexture

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

func (Instance) SetTextureMode

func (self Instance) SetTextureMode(value LineTextureMode)

func (Instance) SetWidth

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

func (Instance) SetWidthCurve

func (self Instance) SetWidthCurve(value Curve.Instance)

func (Instance) SharpLimit

func (self Instance) SharpLimit() Float.X

func (Instance) Texture

func (self Instance) Texture() Texture2D.Instance

func (Instance) TextureMode

func (self Instance) TextureMode() LineTextureMode

func (Instance) Virtual

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

func (Instance) Width

func (self Instance) Width() Float.X

func (Instance) WidthCurve

func (self Instance) WidthCurve() Curve.Instance

type LineCapMode

type LineCapMode int //gd:Line2D.LineCapMode
const (
	// Draws no line cap.
	LineCapNone LineCapMode = 0
	// Draws the line cap as a box, slightly extending the first/last segment.
	LineCapBox LineCapMode = 1
	// Draws the line cap as a semicircle attached to the first/last segment.
	LineCapRound LineCapMode = 2
)

type LineJointMode

type LineJointMode int //gd:Line2D.LineJointMode
const (
	// Makes the polyline's joints pointy, connecting the sides of the two segments by extending them until they intersect. If the rotation of a joint is too big (based on [Instance.SharpLimit]), the joint falls back to [LineJointBevel] to prevent very long miters.
	LineJointSharp LineJointMode = 0
	// Makes the polyline's joints bevelled/chamfered, connecting the sides of the two segments with a simple line.
	LineJointBevel LineJointMode = 1
	// Makes the polyline's joints rounded, connecting the sides of the two segments with an arc. The detail of this arc depends on [Instance.RoundPrecision].
	LineJointRound LineJointMode = 2
)

type LineTextureMode

type LineTextureMode int //gd:Line2D.LineTextureMode
const (
	// Takes the left pixels of the texture and renders them over the whole polyline.
	LineTextureNone LineTextureMode = 0
	// Tiles the texture over the polyline. [graphics.gd/classdb/CanvasItem.Instance.TextureRepeat] of the [graphics.gd/classdb/Line2D] node must be [Canvasitem.TextureRepeatEnabled] or [Canvasitem.TextureRepeatMirror] for it to work properly.
	LineTextureTile LineTextureMode = 1
	// Stretches the texture across the polyline. [graphics.gd/classdb/CanvasItem.Instance.TextureRepeat] of the [graphics.gd/classdb/Line2D] node must be [Canvasitem.TextureRepeatDisabled] for best results.
	LineTextureStretch LineTextureMode = 2
)

Jump to

Keyboard shortcuts

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