A 2D line.
    public class Line2D : Node2D

A line through several points in 2D space.

Inheritance Chain

Constructors

    public Line2D()

Properties

    public LineCapMode BeginCapMode { get; set; }

Controls the style of the line’s first point. Use LINE_CAP_* constants.

    public Color DefaultColor { get; set; }

The line’s color. Will not be used if a gradient is set.

    public LineCapMode EndCapMode { get; set; }

Controls the style of the line’s last point. Use LINE_CAP_* constants.

    public Gradient Gradient { get; set; }

The gradient is drawn through the whole line from start to finish. The default color will not be used if a gradient is set.

    public LineJointMode JointMode { get; set; }

The style for the points between the start and the end.

    public Vector2[] Points { get; set; }

The points that form the lines. The line is drawn between every point set in this array.

    public int RoundPrecision { get; set; }

The smoothness of the rounded joints and caps. This is only used if a cap or joint is set as round.

    public float SharpLimit { get; set; }

The direction difference in radians between vector points. This value is only used if joint mode is set to [constant LINE_JOINT_SHARP].

    public Texture Texture { get; set; }

The texture used for the line’s texture. Uses texture_mode for drawing style.

    public LineTextureMode TextureMode { get; set; }

The style to render the texture on the line. Use LINE_TEXTURE_* constants.

    public float Width { get; set; }

The line’s width.

    public Curve WidthCurve { get; set; }

The line’s width varies with the curve. The original width is simply multiply by the value of the Curve.

Methods

    public void AddPoint(Vector2 position, int atPosition = -1)

Adds a point at the position. Appends the point at the end of the line.

If atPosition is given, the point is inserted before the point number atPosition, moving that point (and every point after) after the inserted point. If atPosition is not given, or is an illegal value (at_position < 0 or at_position >= [GetPointCount()](../Godot.Line2D/#GetPointCount())), the point will be appended at the end of the point list.

    public void ClearPoints()

Removes all points from the line.

    [Obsolete("GetBeginCapMode is deprecated. Use the BeginCapMode property instead.")]
    public LineCapMode GetBeginCapMode()

Getter for BeginCapMode

    [Obsolete("GetCurve is deprecated. Use the WidthCurve property instead.")]
    public Curve GetCurve()

Getter for WidthCurve

    [Obsolete("GetDefaultColor is deprecated. Use the DefaultColor property instead.")]
    public Color GetDefaultColor()

Getter for DefaultColor

    [Obsolete("GetEndCapMode is deprecated. Use the EndCapMode property instead.")]
    public LineCapMode GetEndCapMode()

Getter for EndCapMode

    [Obsolete("GetGradient is deprecated. Use the Gradient property instead.")]
    public Gradient GetGradient()

Getter for Gradient

    [Obsolete("GetJointMode is deprecated. Use the JointMode property instead.")]
    public LineJointMode GetJointMode()

Getter for JointMode

    public int GetPointCount()

Returns the Line2D’s amount of points.

    public Vector2 GetPointPosition(int i)

Returns point i’s position.

    [Obsolete("GetPoints is deprecated. Use the Points property instead.")]
    public Vector2[] GetPoints()

Getter for Points

    [Obsolete("GetRoundPrecision is deprecated. Use the RoundPrecision property instead.")]
    public int GetRoundPrecision()

Getter for RoundPrecision

    [Obsolete("GetSharpLimit is deprecated. Use the SharpLimit property instead.")]
    public float GetSharpLimit()

Getter for SharpLimit

    [Obsolete("GetTexture is deprecated. Use the Texture property instead.")]
    public Texture GetTexture()

Getter for Texture

    [Obsolete("GetTextureMode is deprecated. Use the TextureMode property instead.")]
    public LineTextureMode GetTextureMode()

Getter for TextureMode

    [Obsolete("GetWidth is deprecated. Use the Width property instead.")]
    public float GetWidth()

Getter for Width

    public void RemovePoint(int i)

Removes the point at index i from the line.

    [Obsolete("SetBeginCapMode is deprecated. Use the BeginCapMode property instead.")]
    public void SetBeginCapMode(LineCapMode mode)

Setter for BeginCapMode

    [Obsolete("SetCurve is deprecated. Use the WidthCurve property instead.")]
    public void SetCurve(Curve curve)

Setter for WidthCurve

    [Obsolete("SetDefaultColor is deprecated. Use the DefaultColor property instead.")]
    public void SetDefaultColor(Color color)

Setter for DefaultColor

    [Obsolete("SetEndCapMode is deprecated. Use the EndCapMode property instead.")]
    public void SetEndCapMode(LineCapMode mode)

Setter for EndCapMode

    [Obsolete("SetGradient is deprecated. Use the Gradient property instead.")]
    public void SetGradient(Gradient color)

Setter for Gradient

    [Obsolete("SetJointMode is deprecated. Use the JointMode property instead.")]
    public void SetJointMode(LineJointMode mode)

Setter for JointMode

    public void SetPointPosition(int i, Vector2 position)

Overwrites the position in point i with the supplied position.

    [Obsolete("SetPoints is deprecated. Use the Points property instead.")]
    public void SetPoints(Vector2[] points)

Setter for Points

    [Obsolete("SetRoundPrecision is deprecated. Use the RoundPrecision property instead.")]
    public void SetRoundPrecision(int precision)

Setter for RoundPrecision

    [Obsolete("SetSharpLimit is deprecated. Use the SharpLimit property instead.")]
    public void SetSharpLimit(float limit)

Setter for SharpLimit

    [Obsolete("SetTexture is deprecated. Use the Texture property instead.")]
    public void SetTexture(Texture texture)

Setter for Texture

    [Obsolete("SetTextureMode is deprecated. Use the TextureMode property instead.")]
    public void SetTextureMode(LineTextureMode mode)

Setter for TextureMode

    [Obsolete("SetWidth is deprecated. Use the Width property instead.")]
    public void SetWidth(float width)

Setter for Width

Inner Types

LineCapMode

Name Value Description
None 0 Don’t draw a line cap.
Box 1 Draws the line cap as a box.
Round 2 Draws the line cap as a circle.

LineJointMode

Name Value Description
Sharp 0 The line’s joints will be pointy. If [code]sharp_limit[/code] is greater than the rotation of a joint, it becomes a bevel joint instead.
Bevel 1 The line’s joints will be bevelled/chamfered.
Round 2 The line’s joints will be rounded.

LineTextureMode

Name Value Description
None 0 Takes the left pixels of the texture and renders it over the whole line.
Tile 1 Tiles the texture over the line. The texture must be imported with [b]Repeat[/b] enabled for it to work properly.
Stretch 2 Stretches the texture across the line. Import the texture with [b]Repeat[/b] disabled for best results.
Tags: