Inheritance #
- AudioServer
- CameraServer
- ClassDB
- DisplayServer
- EditorFileSystemDirectory
- EditorInterface
- EditorPaths
- EditorSelection
- EditorUndoRedoManager
- EditorVCSInterface
- Engine
- EngineDebugger
- FramebufferCacheRD
- GDExtensionManager
- Geometry2D
- Geometry3D
- IP
- Input
- InputMap
- JNISingleton
- JSONRPC
- JavaClassWrapper
- JavaScriptBridge
- MainLoop (1)
- Marshalls
- MovieWriter
- NativeMenu
- NavigationMeshGenerator
- NavigationServer2D
- NavigationServer3D
- Node (21)
- OS
- OpenXRExtensionWrapperExtension
- OpenXRInteractionProfileMetadata
- Performance
- PhysicsDirectBodyState2D (1)
- PhysicsDirectBodyState3D (1)
- PhysicsDirectSpaceState2D (1)
- PhysicsDirectSpaceState3D (1)
- PhysicsServer2D (1)
- PhysicsServer2DManager
- PhysicsServer3D (1)
- PhysicsServer3DManager
- PhysicsServer3DRendering
ServerHandler
- ProjectSettings
- RefCounted (121)
- RenderData (2)
- RenderSceneData (2)
- RenderingDevice
- RenderingServer
- ResourceLoader
- ResourceSaver
- ResourceUID
- ScriptLanguage (1)
- ShaderIncludeDB
- TextServerManager
- ThemeDB
- TileData
- Time
- TranslationServer
- TreeItem
- UndoRedo
- UniformSetCacheRD
- WorkerThreadPool
- XRServer
- XRVRS
- AnimationMixer (2)
- AudioStreamPlayer
- CanvasItem (2)
- CanvasLayer (1)
- EditorFileSystem
- EditorPlugin (1)
- EditorResourcePreview
- HTTPRequest
- InstancePlaceholder
- MissingNode
- MultiplayerSpawner
- MultiplayerSynchronizer
- NavigationAgent2D
- NavigationAgent3D
- Node3D (31)
- ResourcePreloader
- ShaderGlobalsOverride
- StatusIndicator
- Timer
- Viewport (2)
- WorldEnvironment
- AnimatedSprite2D
- AudioListener2D
- AudioStreamPlayer2D
- BackBufferCopy
- Bone2D
- CPUParticles2D
- Camera2D
- CanvasGroup
- CanvasModulate
- CollisionObject2D (2)
- CollisionPolygon2D
- CollisionShape2D
- GPUParticles2D
- Joint2D (3)
- Light2D (2)
- LightOccluder2D
- Line2D
- Marker2D
- MeshInstance2D
- MultiMeshInstance2D
- NavigationLink2D
- NavigationObstacle2D
- NavigationRegion2D
- Parallax2D
- ParallaxLayer
- Path2D
- PathFollow2D
- Polygon2D
- RayCast2D
- RemoteTransform2D
- ShapeCast2D
- Skeleton2D
- Sprite2D
- TileMap
- TileMapLayer
- TouchScreenButton
- VisibleOnScreenNotifier2D (1)
Table of contents
-
var antialiased: bool = false -
var begin_cap_mode = LINE_CAP_NONE -
var closed: bool = false -
var default_color: Color = Color(1, 1, 1, 1) -
var end_cap_mode = LINE_CAP_NONE -
var gradient: Gradient -
var joint_mode = LINE_JOINT_SHARP -
var points: PackedVector2Array = PackedVector2Array() -
var round_precision: int = 8 -
var sharp_limit: float = 2.0 -
var texture: Texture2D -
var texture_mode = LINE_TEXTURE_NONE -
var width: float = 10.0 -
var width_curve: Curve -
func add_point(index: int = -1) -> void -
func clear_points() -> void -
const func get_point_count() -> int -
const func get_point_position(index: int) -> Vector2 -
func remove_point(index: int) -> void -
func set_point_position(position: Vector2) -> void -
const LINE_JOINT_SHARP = 0 enum LineJointMode -
const LINE_JOINT_BEVEL = 1 enum LineJointMode -
const LINE_JOINT_ROUND = 2 enum LineJointMode -
const LINE_CAP_NONE = 0 enum LineCapMode -
const LINE_CAP_BOX = 1 enum LineCapMode -
const LINE_CAP_ROUND = 2 enum LineCapMode -
const LINE_TEXTURE_NONE = 0 enum LineTextureMode -
const LINE_TEXTURE_TILE = 1 enum LineTextureMode -
const LINE_TEXTURE_STRETCH = 2 enum LineTextureMode -
enum LineJointMode -
enum LineCapMode -
enum LineTextureMode
Line2D #
is_instantiable, Node2D, Node, core, not_builtin_classes
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.
Members #
var antialiased: bool = false#
If true, the polyline's border will be anti-aliased.
Note: Line2D is not accelerated by batching when being anti-aliased.
var begin_cap_mode = LINE_CAP_NONE#
The style of the beginning of the polyline, if closed is false. Use LineCapMode constants.
var closed: bool = false#
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 default_color: Color = Color(1, 1, 1, 1)#
The color of the polyline. Will not be used if a gradient is set.
var end_cap_mode = LINE_CAP_NONE#
The style of the end of the polyline, if closed is false. Use LineCapMode constants.
var gradient: 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 joint_mode = LINE_JOINT_SHARP#
The style of the connections between segments of the polyline. Use LineJointMode constants.
var points: PackedVector2Array = PackedVector2Array()#
The points of the polyline, interpreted in local 2D coordinates. Segments are drawn between the adjacent points in this array.
var round_precision: int = 8#
The smoothness used for rounded joints and caps. Higher values result in smoother corners, but are more demanding to render and update.
var sharp_limit: float = 2.0#
Determines the miter limit of the polyline. Normally, when joint_mode is set to LINE_JOINT_SHARP, sharp angles fall back to using the logic of 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 texture: Texture2D#
The texture used for the polyline. Uses texture_mode for drawing style.
var texture_mode = LINE_TEXTURE_NONE#
The style to render the texture of the polyline. Use LineTextureMode constants.
var width: float = 10.0#
The polyline's width.
var width_curve: 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.
Methods #
func add_point(index: int = -1) -> void#
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.
func clear_points() -> void#
Removes all points from the polyline, making it empty.
const func get_point_count() -> int#
Returns the number of points in the polyline.
const func get_point_position(index: int) -> Vector2#
Returns the position of the point at index index.
func remove_point(index: int) -> void#
Removes the point at index index from the polyline.
func set_point_position(position: Vector2) -> void#
Overwrites the position of the point at the given index with the supplied position.
Annotations #
Constants #
const LINE_JOINT_SHARP = 0 enum LineJointMode#
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 sharp_limit), the joint falls back to LINE_JOINT_BEVEL to prevent very long miters.
const LINE_JOINT_BEVEL = 1 enum LineJointMode#
Makes the polyline's joints bevelled/chamfered, connecting the sides of the two segments with a simple line.
const LINE_JOINT_ROUND = 2 enum LineJointMode#
Makes the polyline's joints rounded, connecting the sides of the two segments with an arc. The detail of this arc depends on round_precision.
const LINE_CAP_NONE = 0 enum LineCapMode#
Draws no line cap.
const LINE_CAP_BOX = 1 enum LineCapMode#
Draws the line cap as a box, slightly extending the first/last segment.
const LINE_CAP_ROUND = 2 enum LineCapMode#
Draws the line cap as a semicircle attached to the first/last segment.
const LINE_TEXTURE_NONE = 0 enum LineTextureMode#
Takes the left pixels of the texture and renders them over the whole polyline.
const LINE_TEXTURE_TILE = 1 enum LineTextureMode#
Tiles the texture over the polyline. CanvasItem.texture_repeat of the Line2D node must be CanvasItem.TEXTURE_REPEAT_ENABLED or CanvasItem.TEXTURE_REPEAT_MIRROR for it to work properly.
const LINE_TEXTURE_STRETCH = 2 enum LineTextureMode#
Stretches the texture across the polyline. CanvasItem.texture_repeat of the Line2D node must be CanvasItem.TEXTURE_REPEAT_DISABLED for best results.
Constructors #
Enums #
LineJointMode#
enum LineJointMode {
LINE_JOINT_SHARP = 0,
LINE_JOINT_BEVEL = 1,
LINE_JOINT_ROUND = 2,
}LineCapMode#
enum LineCapMode {
LINE_CAP_NONE = 0,
LINE_CAP_BOX = 1,
LINE_CAP_ROUND = 2,
}LineTextureMode#
enum LineTextureMode {
LINE_TEXTURE_NONE = 0,
LINE_TEXTURE_TILE = 1,
LINE_TEXTURE_STRETCH = 2,
}