Table of Contents

Class Line2D

A 2D polyline that can optionally be textured.

Inheritance
Line2D

Remarks

This node draws a 2D polyline, i.e. a shape consisting of several points connected by segments. 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: Line2D is drawn using a 2D mesh.

See Also

Properties

antialiased

If true, the polyline's border will be anti-aliased.

Note: Line2D is not accelerated by batching when being anti-aliased.

var antialiased : bool = false

Property Value

bool

Remarks

  • void set_antialiased(bool value)
  • bool get_antialiased

begin_cap_mode

The style of the beginning of the polyline, if closed is false. Use LineCapMode constants.

var begin_cap_mode : int = 0

Property Value

int

Remarks

  • void set_begin_cap_mode(int value)
  • int get_begin_cap_mode

closed

If true and the polyline has more than 2 points, the last point and the first one will be connected by a segment.

Note: The shape of the closing segment is not guaranteed to be seamless if a width_curve is provided.

Note: The joint between the closing segment and the first segment is drawn first and it samples the gradient and the width_curve at the beginning. This is an implementation detail that might change in a future version.

var closed : bool = false

Property Value

bool

Remarks

  • void set_closed(bool value)
  • bool is_closed

default_color

The color of the polyline. Will not be used if a gradient is set.

var default_color : Color = Color(1, 1, 1, 1)

Property Value

Color

Remarks

  • void set_default_color(Color value)
  • Color get_default_color

end_cap_mode

The style of the end of the polyline, if closed is false. Use LineCapMode constants.

var end_cap_mode : int = 0

Property Value

int

Remarks

  • void set_end_cap_mode(int value)
  • int get_end_cap_mode

gradient

The gradient is drawn through the whole line from start to finish. The default_color will not be used if this property is set.

var gradient : Gradient

Property Value

Gradient

Remarks

joint_mode

The style of the connections between segments of the polyline. Use LineJointMode constants.

var joint_mode : int = 0

Property Value

int

Remarks

  • void set_joint_mode(int value)
  • int get_joint_mode

points

The points of the polyline, interpreted in local 2D coordinates. Segments are drawn between the adjacent points in this array.

var points : PackedVector2Array = PackedVector2Array()

Property Value

PackedVector2Array

Remarks

round_precision

The smoothness used for rounded joints and caps. Higher values result in smoother corners, but are more demanding to render and update.

var round_precision : int = 8

Property Value

int

Remarks

  • void set_round_precision(int value)
  • int get_round_precision

sharp_limit

Determines the miter limit of the polyline. Normally, when joint_mode is set to Line2D.LINE_JOINT_SHARP, sharp angles fall back to using the logic of Line2D.LINE_JOINT_BEVEL joints to prevent very long miters. Higher values of this property mean that the fallback to a bevel joint will happen at sharper angles.

var sharp_limit : float = 2.0

Property Value

float

Remarks

  • void set_sharp_limit(float value)
  • float get_sharp_limit

texture

The texture used for the polyline. Uses texture_mode for drawing style.

var texture : Texture2D

Property Value

Texture2D

Remarks

texture_mode

The style to render the texture of the polyline. Use LineTextureMode constants.

var texture_mode : int = 0

Property Value

int

Remarks

  • void set_texture_mode(int value)
  • int get_texture_mode

width

The polyline's width.

var width : float = 10.0

Property Value

float

Remarks

width_curve

The polyline's width curve. The width of the polyline over its length will be equivalent to the value of the width curve over its domain. The width curve should be a unit Curve.

var width_curve : Curve

Property Value

Curve

Remarks

Methods

add_point(Vector2, 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 get_point_count.

void add_point(Vector2 position, int index)

Parameters

position Vector2
index int

clear_points

Removes all points from the polyline, making it empty.

void clear_points

get_point_count

Qualifiers: const

Returns the number of points in the polyline.

int get_point_count

get_point_position(int)

Qualifiers: const

Returns the position of the point at index index.

Vector2 get_point_position(int index)

Parameters

index int

remove_point(int)

Removes the point at index index from the polyline.

void remove_point(int index)

Parameters

index int

set_point_position(int, Vector2)

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

void set_point_position(int index, Vector2 position)

Parameters

index int
position Vector2