Line2D
A 2D polyline that can optionally be textured.
Line2D.swift:16class Line2D
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.
Superclasses
class Node2D
A 2D game object, inherited by all 2D-related nodes. Has a position, rotation, scale, and Z index.
Citizens in SwiftGodot
Conformances
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol Identifiable<ID>
A class of types whose instances hold the value of an entity with stable identity.
protocol VariantRepresentable
Types that conform to VariantRepresentable can be stored directly in
Variant
with no conversion. These include all of the Variant types from Godot (for exampleGString
,Rect
,Plane
), Godot objects (those that subclass SwiftGodot.Object) as well as the built-in Swift types UInt8, Int64 and Double.protocol VariantStorable
Types that conform to VariantStorable can be stored in a Variant and can be extracted back out of a Variant.
Types
Type members
Instance members
var antialiased: Bool
If
true
, the polyline’s border will be anti-aliased.var beginCapMode: Line2D.LineCapMode
The style of the beginning of the polyline, if
closed
isfalse
. UseLineCapMode
constants.var closed: Bool
If
true
and the polyline has more than 2 points, the last point and the first one will be connected by a segment.var defaultColor: Color
The color of the polyline. Will not be used if a gradient is set.
var endCapMode: Line2D.LineCapMode
The style of the end of the polyline, if
closed
isfalse
. UseLineCapMode
constants.var gradient: Gradient?
The gradient is drawn through the whole line from start to finish. The
defaultColor
will not be used if this property is set.var jointMode: Line2D.LineJointMode
The style of the connections between segments of the polyline. Use
LineJointMode
constants.var points: PackedVector2Array
The points of the polyline, interpreted in local 2D coordinates. Segments are drawn between the adjacent points in this array.
var roundPrecision: Int32
The smoothness used for rounded joints and caps. Higher values result in smoother corners, but are more demanding to render and update.
var sharpLimit: Double
Determines the miter limit of the polyline. Normally, when
jointMode
is set to .lineJointSharp, sharp angles fall back to using the logic of .lineJointBevel 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
textureMode
for drawing style.var textureMode: Line2D.LineTextureMode
The style to render the
texture
of the polyline. UseLineTextureMode
constants.var width: Double
The polyline’s width.
var widthCurve: 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.
func addPoint(position: Vector2, index: Int32
) Adds a point with the specified
position
relative to the polyline’s own position. If noindex
is provided, the new point will be added to the end of the points array.func clearPoints(
) Removes all points from the polyline, making it empty.
func getPointCount(
) -> Int32 Returns the number of points in the polyline.
func getPointPosition(index: Int32
) -> Vector2 Returns the position of the point at index
index
.func removePoint(index: Int32
) Removes the point at index
index
from the polyline.func setPointPosition(index: Int32, position: Vector2
) Overwrites the position of the point at the given
index
with the suppliedposition
.