geom

GeomPolyline2DGeom.Nodes.Polyline2D

Inherits: Node2D

C#: make one with the Geom.Nodes.Polyline2D() factory, then set and read its properties by name with Set and Get, or in the Inspector, where the node is GeomPolyline2D.

A path on the canvas.

From code

The code used to generate this page's thumbnail.

var line := GeomPolyline2D.new()
line.position = c
var pts := PackedVector2Array()
pts.resize(25)
for i in 25:
	var u := i / 24.0
	pts[i] = Vector2(-r * 1.15 + u * r * 2.3, -sin(u * TAU) * r * 0.62)
line.points = pts
line.join = Geom.JOIN_ROUND
line.thickness = vp.y * 0.085
line.color = PINK
add_child(line)
var line = Geom.Nodes.Polyline2D();
line.Position = c;
var pts = new Vector2[25];
for (int i = 0; i < 25; i++)
{
	var u = i / 24.0f;
	pts[i] = new Vector2(-r * 1.15f + u * r * 2.3f, -Mathf.Sin(u * Mathf.Tau) * r * 0.62f);
}
line.Set("points", pts);
line.Set("join", (int)Geom.PolylineJoin.Round);
line.Set("thickness", vp.Y * 0.085f);
line.Set("color", PINK);
AddChild(line);

Properties

BlendMode blend_mode Geom.BLEND_TRANSPARENTGeom.BlendMode.Transparent
bool closed false
Color color Color(1, 1, 1, 1)
PolylineJoin join Geom.JOIN_MITERGeom.PolylineJoin.Miter
PackedVector2Array points PackedVector2Array()
float thickness 8.0
ThicknessSpace thickness_space Geom.SPACE_WORLDGeom.ThicknessSpace.World

Enumerations

enum Geom.ThicknessSpace

Geom.SPACE_WORLDGeom.ThicknessSpace.World = 0
World units, the same as a node's position.
Geom.SPACE_VIEWPORT_PIXELSGeom.ThicknessSpace.ViewportPixels = 1
The viewport's pixels. Constant size on screen at any zoom.
Geom.SPACE_VIEWPORT_PERCENTGeom.ThicknessSpace.ViewportPercent = 2
Percent of the viewport's shorter side. Like CSS vmin.

enum Geom.PolylineJoin

Geom.JOIN_SIMPLEGeom.PolylineJoin.Simple = 0
The two segments meet at plain width, so the outside of the corner pinches in.
Geom.JOIN_MITERGeom.PolylineJoin.Miter = 1
The outside edges extend until they meet, clamped on sharp turns.
Geom.JOIN_ROUNDGeom.PolylineJoin.Round = 2
A disc over each corner.
Geom.JOIN_BEVELGeom.PolylineJoin.Bevel = 3
The outside of the corner cut off square.

enum Geom.BlendMode

Geom.BLEND_OPAQUEGeom.BlendMode.Opaque = 0
Sorts by position. Hard edges: no anti-aliasing, and alpha is ignored.
Geom.BLEND_TRANSPARENTGeom.BlendMode.Transparent = 1
Standard alpha blending. The default.
Geom.BLEND_ADDITIVEGeom.BlendMode.Additive = 2
Adds this color to what is behind.
Geom.BLEND_MULTIPLYGeom.BlendMode.Multiply = 3
Multiplies what is behind by this color.
Geom.BLEND_SUBTRACTGeom.BlendMode.Subtract = 4
Subtracts this color from the background.
Geom.BLEND_TRANSPARENT_DEPTHGeom.BlendMode.TransparentDepth = 5
Transparent, but writes depth, so shapes with alpha 1 sort by position with anti-aliased edges. A translucent color behaves like Transparent.

Property descriptions

BlendMode blend_mode = Geom.BLEND_TRANSPARENTGeom.BlendMode.Transparent

How the shape blends with what is behind it. Transparent Depth acts like Transparent on the canvas.

bool closed = false

Join the last point back to the first.

Color color = Color(1, 1, 1, 1)

Line color.

PolylineJoin join = Geom.JOIN_MITERGeom.PolylineJoin.Miter

How corners are drawn.

PackedVector2Array points = PackedVector2Array()

The path. Fewer than two points draws nothing.

float thickness = 8.0

Line width.

ThicknessSpace thickness_space = Geom.SPACE_WORLDGeom.ThicknessSpace.World

How thickness is measured.