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
Remarks
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
Remarks
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
Remarks
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
Remarks
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
Remarks
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
Remarks
joint_mode
The style of the connections between segments of the polyline. Use LineJointMode constants.
var joint_mode : int = 0
Property Value
Remarks
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
Remarks
- void set_points(PackedVector2Array value)
- PackedVector2Array get_points
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
Remarks
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
Remarks
texture
The texture used for the polyline. Uses texture_mode for drawing style.
var texture : Texture2D
Property Value
Remarks
texture_mode
The style to render the texture of the polyline. Use LineTextureMode constants.
var texture_mode : int = 0
Property Value
Remarks
width
The polyline's width.
var width : float = 10.0
Property Value
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
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
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)