Line2D
A 2D polyline that can optionally be textured.
A 2D polyline that can optionally be textured.
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.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
Line2DConstructor
public Line2D();Properties14
AntialiasedProperty
public bool Antialiased { get; set; }If true, the polyline's border will be anti-aliased.
Note: Line2D is not accelerated by batching when being anti-aliased.
BeginCapModeProperty
public Line2D.LineCapMode BeginCapMode { get; set; }The style of the beginning of the polyline, if Line2D.Closed is false.
ClosedProperty
public bool Closed { get; set; }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 Line2D.WidthCurve is provided.
Note: The joint between the closing segment and the first segment is drawn first and it samples the Line2D.Gradient and the Line2D.WidthCurve at the beginning. This is an implementation detail that might change in a future version.
DefaultColorProperty
public Color DefaultColor { get; set; }The color of the polyline. Will not be used if a gradient is set.
EndCapModeProperty
public Line2D.LineCapMode EndCapMode { get; set; }The style of the end of the polyline, if Line2D.Closed is false.
GradientProperty
public Gradient Gradient { get; set; }The gradient is drawn through the whole line from start to finish. The Line2D.DefaultColor will not be used if this property is set.
JointModeProperty
public Line2D.LineJointMode JointMode { get; set; }The style of the connections between segments of the polyline.
PointsProperty
public Vector2[] Points { get; set; }The points of the polyline, interpreted in local 2D coordinates. Segments are drawn between the adjacent points in this array.
RoundPrecisionProperty
public int RoundPrecision { get; set; }The smoothness used for rounded joints and caps. Higher values result in smoother corners, but are more demanding to render and update.
SharpLimitProperty
public float SharpLimit { get; set; }Determines the miter limit of the polyline. Normally, when Line2D.JointMode is set to Line2D.LineJointMode.Sharp, sharp angles fall back to using the logic of Line2D.LineJointMode.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.
TextureProperty
public Texture2D Texture { get; set; }The texture used for the polyline. Uses Line2D.TextureMode for drawing style.
TextureModeProperty
public Line2D.LineTextureMode TextureMode { get; set; }The style to render the Line2D.Texture of the polyline.
WidthProperty
public float Width { get; set; }The polyline's width.
WidthCurveProperty
public Curve WidthCurve { get; set; }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.
Methods35
AddPointvoid
public void AddPoint(Vector2 position, int index = -1);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 Line2D.GetPointCount.
| Name | Type | Default |
|---|---|---|
position | Vector2 | — |
index | int | -1 |
ClearPointsvoid
public void ClearPoints();Removes all points from the polyline, making it empty.
GetAntialiasedbool
public bool GetAntialiased();boolGetBeginCapModeLine2D.LineCapMode
public Line2D.LineCapMode GetBeginCapMode();Line2D.LineCapModeGetCurveCurve
public Curve GetCurve();CurveGetDefaultColorColor
public Color GetDefaultColor();ColorGetEndCapModeLine2D.LineCapMode
public Line2D.LineCapMode GetEndCapMode();Line2D.LineCapModeGetGradientGradient
public Gradient GetGradient();GradientGetJointModeLine2D.LineJointMode
public Line2D.LineJointMode GetJointMode();Line2D.LineJointModeGetPointCountint
public int GetPointCount();Returns the number of points in the polyline.
intGetPointPositionVector2
public Vector2 GetPointPosition(int index);Returns the position of the point at index index.
| Name | Type | Default |
|---|---|---|
index | int | — |
Vector2GetPointsVector2[]
public Vector2[] GetPoints();Vector2[]GetRoundPrecisionint
public int GetRoundPrecision();intGetSharpLimitfloat
public float GetSharpLimit();floatGetTextureTexture2D
public Texture2D GetTexture();Texture2DGetTextureModeLine2D.LineTextureMode
public Line2D.LineTextureMode GetTextureMode();Line2D.LineTextureModeGetWidthfloat
public float GetWidth();floatIsClosedbool
public bool IsClosed();boolRemovePointvoid
public void RemovePoint(int index);Removes the point at index index from the polyline.
| Name | Type | Default |
|---|---|---|
index | int | — |
SetAntialiasedvoid
public void SetAntialiased(bool antialiased);| Name | Type | Default |
|---|---|---|
antialiased | bool | — |
SetBeginCapModevoid
public void SetBeginCapMode(Line2D.LineCapMode mode);| Name | Type | Default |
|---|---|---|
mode | Line2D.LineCapMode | — |
SetClosedvoid
public void SetClosed(bool closed);| Name | Type | Default |
|---|---|---|
closed | bool | — |
SetCurvevoid
public void SetCurve(Curve curve);| Name | Type | Default |
|---|---|---|
curve | Curve | — |
SetDefaultColorvoid
public void SetDefaultColor(Color color);| Name | Type | Default |
|---|---|---|
color | Color | — |
SetEndCapModevoid
public void SetEndCapMode(Line2D.LineCapMode mode);| Name | Type | Default |
|---|---|---|
mode | Line2D.LineCapMode | — |
SetGradientvoid
public void SetGradient(Gradient color);| Name | Type | Default |
|---|---|---|
color | Gradient | — |
SetJointModevoid
public void SetJointMode(Line2D.LineJointMode mode);| Name | Type | Default |
|---|---|---|
mode | Line2D.LineJointMode | — |
SetPointPositionvoid
public void SetPointPosition(int index, Vector2 position);Overwrites the position of the point at the given index with the supplied position.
| Name | Type | Default |
|---|---|---|
index | int | — |
position | Vector2 | — |
SetPoints2 overloads
public void SetPoints(Vector2[] points);| Name | Type | Default |
|---|---|---|
points | Vector2[] | — |
public void SetPoints(ReadOnlySpan<Vector2> points);| Name | Type | Default |
|---|---|---|
points | ReadOnlySpan<Vector2> | — |
SetRoundPrecisionvoid
public void SetRoundPrecision(int precision);| Name | Type | Default |
|---|---|---|
precision | int | — |
SetSharpLimitvoid
public void SetSharpLimit(float limit);| Name | Type | Default |
|---|---|---|
limit | float | — |
SetTexturevoid
public void SetTexture(Texture2D texture);| Name | Type | Default |
|---|---|---|
texture | Texture2D | — |
SetTextureModevoid
public void SetTextureMode(Line2D.LineTextureMode mode);| Name | Type | Default |
|---|---|---|
mode | Line2D.LineTextureMode | — |
SetWidthvoid
public void SetWidth(float width);| Name | Type | Default |
|---|---|---|
width | float | — |
Line2D.LineCapMode
Line2D.LineJointMode
| Value | Description |
|---|---|
Bevel = 1 | Makes the polyline's joints bevelled/chamfered, connecting the sides of the two segments with a simple line. |
Round = 2 | Makes the polyline's joints rounded, connecting the sides of the two segments with an arc. The detail of this arc depends on |
Sharp = 0 | 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 |
Line2D.LineTextureMode
| Value | Description |
|---|---|
None = 0 | Takes the left pixels of the texture and renders them over the whole polyline. |
Stretch = 2 | Stretches the texture across the polyline. |
Tile = 1 | Tiles the texture over the polyline. |