Class Line2D
- Namespace
- Godot
- Assembly
- GodotSharp.dll
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.
public class Line2D : Node2D, IDisposable
- Inheritance
-
Line2D
- Implements
- Inherited Members
Constructors
Line2D()
public Line2D()
Properties
Antialiased
If true
, the polyline's border will be anti-aliased.
Note: Line2D is not accelerated by batching when being anti-aliased.
public bool Antialiased { get; set; }
Property Value
BeginCapMode
The style of the beginning of the polyline, if Closed is false
. Use Line2D.LineCapMode constants.
public Line2D.LineCapMode BeginCapMode { get; set; }
Property Value
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 WidthCurve is provided.
Note: The joint between the closing segment and the first segment is drawn first and it samples the Gradient and the WidthCurve at the beginning. This is an implementation detail that might change in a future version.
public bool Closed { get; set; }
Property Value
DefaultColor
The color of the polyline. Will not be used if a gradient is set.
public Color DefaultColor { get; set; }
Property Value
EndCapMode
The style of the end of the polyline, if Closed is false
. Use Line2D.LineCapMode constants.
public Line2D.LineCapMode EndCapMode { get; set; }
Property Value
Gradient
The gradient is drawn through the whole line from start to finish. The DefaultColor will not be used if this property is set.
public Gradient Gradient { get; set; }
Property Value
JointMode
The style of the connections between segments of the polyline. Use Line2D.LineJointMode constants.
public Line2D.LineJointMode JointMode { get; set; }
Property Value
Points
The points of the polyline, interpreted in local 2D coordinates. Segments are drawn between the adjacent points in this array.
public Vector2[] Points { get; set; }
Property Value
- Vector2[]
RoundPrecision
The smoothness used for rounded joints and caps. Higher values result in smoother corners, but are more demanding to render and update.
public int RoundPrecision { get; set; }
Property Value
SharpLimit
Determines the miter limit of the polyline. Normally, when JointMode is set to Sharp, sharp angles fall back to using the logic of 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.
public float SharpLimit { get; set; }
Property Value
Texture
The texture used for the polyline. Uses TextureMode for drawing style.
public Texture2D Texture { get; set; }
Property Value
TextureMode
The style to render the Texture of the polyline. Use Line2D.LineTextureMode constants.
public Line2D.LineTextureMode TextureMode { get; set; }
Property Value
Width
The polyline's width.
public float Width { get; set; }
Property Value
WidthCurve
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.
public Curve WidthCurve { get; set; }
Property Value
Methods
AddPoint(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 GetPointCount().
public void AddPoint(Vector2 position, int index = -1)
Parameters
ClearPoints()
Removes all points from the polyline, making it empty.
public void ClearPoints()
GetPointCount()
Returns the number of points in the polyline.
public int GetPointCount()
Returns
GetPointPosition(int)
Returns the position of the point at index index
.
public Vector2 GetPointPosition(int index)
Parameters
index
int
Returns
HasGodotClassMethod(in godot_string_name)
Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.
protected override bool HasGodotClassMethod(in godot_string_name method)
Parameters
method
godot_string_nameName of the method to check for.
Returns
HasGodotClassSignal(in godot_string_name)
Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.
protected override bool HasGodotClassSignal(in godot_string_name signal)
Parameters
signal
godot_string_nameName of the signal to check for.
Returns
InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)
Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.
protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)
Parameters
method
godot_string_nameName of the method to invoke.
args
NativeVariantPtrArgsArguments to use with the invoked method.
ret
godot_variantValue returned by the invoked method.
Returns
RemovePoint(int)
Removes the point at index index
from the polyline.
public void RemovePoint(int index)
Parameters
index
int
SetPointPosition(int, Vector2)
Overwrites the position of the point at the given index
with the supplied position
.
public void SetPointPosition(int index, Vector2 position)