Line2D

Inherits: Node2D < CanvasItem < Node < Object

Category: Core

Brief Description

A 2D line.

Properties

LineCapModebegin_cap_mode
Colordefault_color
LineCapModeend_cap_mode
Gradientgradient
LineJointModejoint_mode
PoolVector2Arraypoints
intround_precision
floatsharp_limit
Texturetexture
LineTextureModetexture_mode
floatwidth

Methods

voidadd_point ( Vector2 position )
voidclear_points ( )
intget_point_count ( ) const
Vector2get_point_position ( int i ) const
voidremove_point ( int i )
voidset_point_position ( int i, Vector2 position )

Enumerations

enum LineJointMode:

  • LINE_JOINT_SHARP = 0 — The line’s joints will be pointy. If sharp_limit is greater than the rotation of a joint, it becomes a bevel joint instead.
  • LINE_JOINT_BEVEL = 1 — The line’s joints will be bevelled/chamfered.
  • LINE_JOINT_ROUND = 2 — The line’s joints will be rounded.

enum LineCapMode:

  • LINE_CAP_NONE = 0 — Don’t have a line cap.
  • LINE_CAP_BOX = 1 — Draws the line cap as a box.
  • LINE_CAP_ROUND = 2 — Draws the line cap as a circle.

enum LineTextureMode:

  • LINE_TEXTURE_NONE = 0 — Takes the left pixels of the texture and renders it over the whole line.
  • LINE_TEXTURE_TILE = 1 — Tiles the texture over the line. The texture need to be imported with Repeat Enabled for it to work properly.
  • LINE_TEXTURE_STRETCH = 2 — Stretches the texture across the line. Import the texture with Repeat Disabled for best results.

Description

A line through several points in 2D space.

Property Descriptions

Setterset_begin_cap_mode(value)
Getterget_begin_cap_mode()

Controls the style of the line’s first point. Use LINE_CAP_* constants. Default value: LINE_CAP_NONE.


Setterset_default_color(value)
Getterget_default_color()

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


Setterset_end_cap_mode(value)
Getterget_end_cap_mode()

Controls the style of the line’s last point. Use LINE_CAP_* constants. Default value: LINE_CAP_NONE.


Setterset_gradient(value)
Getterget_gradient()

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


Setterset_joint_mode(value)
Getterget_joint_mode()

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


Setterset_points(value)
Getterget_points()

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


  • int round_precision
Setterset_round_precision(value)
Getterget_round_precision()

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


Setterset_sharp_limit(value)
Getterget_sharp_limit()

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


Setterset_texture(value)
Getterget_texture()

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


Setterset_texture_mode(value)
Getterget_texture_mode()

The style to render the texture on the line. Use LINE_TEXTURE_* constants. Default value: LINE_TEXTURE_NONE.


Setterset_width(value)
Getterget_width()

The line’s width.

Method Descriptions

  • void add_point ( Vector2 position )

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


  • void clear_points ( )

Removes all points from the line.


  • int get_point_count ( ) const

Returns the Line2D’s amount of points.


Returns point i’s position.


  • void remove_point ( int i )

Remove the point at index i from the line.


  • void set_point_position ( int i, Vector2 position )

Overwrites the position in point i with the supplied position.