geom

GeomLine2D

Inherits: Node2D

A line segment on the canvas.

Drawing it

The code behind the picture above, where vp is the picture's size, c is its centre, r is 30% of its height.

GeomDraw.line_end_cap = Geom.CAP_ROUND
GeomDraw.thickness = vp.y * 0.09
GeomDraw.line_2d_colored(c + Vector2(-r, r * 0.6), c + Vector2(r, -r * 0.6), ROSE)

Properties

BlendMode blend_mode Geom.BLEND_TRANSPARENT
Color color Color(1, 1, 1, 1)
Color color_end Color(1, 1, 1, 1)
GeomDash dash null
Vector2 end Vector2(100, 0)
LineEndCap end_cap Geom.CAP_ROUND
bool gradient false
Vector2 start Vector2(-100, 0)
float thickness 8.0
ThicknessSpace thickness_space Geom.SPACE_METERS

Enumerations

enum Geom.ThicknessSpace

Geom.SPACE_METERS = 0
Thickness in world units; shrinks on screen with distance.
Geom.SPACE_PIXELS = 1
Thickness in screen pixels; constant on-screen size.
Geom.SPACE_VIEWPORT = 2
A fraction of the viewport: 100 span its shorter side, so 1 is one percent of it and about 11 pixels at 1080p. The same idea as CSS vmin. Radii and sizes here are whole-ish numbers; strokes come out below 1, and a stroke that should stay a fixed pixel width wants SPACE_PIXELS instead.

enum Geom.LineEndCap

Geom.CAP_NONE = 0
Cut off exactly at each endpoint.
Geom.CAP_SQUARE = 1
Extend by half the thickness at each endpoint.
Geom.CAP_ROUND = 2
Extend by half the thickness, rounded.

enum Geom.BlendMode

Geom.BLEND_OPAQUE = 0
Writes depth and sorts against other geometry; hard edges, no fade.
Geom.BLEND_TRANSPARENT = 1
Standard alpha compositing. The default.
Geom.BLEND_ADDITIVE = 2
Brightens what is behind. Good for glows.
Geom.BLEND_MULTIPLY = 3
Darkens what is behind. Good for tints.
Geom.BLEND_SUBTRACT = 4
Subtracts this color from the background.
Geom.BLEND_TRANSPARENT_DEPTH = 5
Transparent, but writing depth so shapes occlude by position.

Property descriptions

BlendMode blend_mode = Geom.BLEND_TRANSPARENT

How the shape combines with what is behind it. Transparent Depth is a 3D idea and behaves exactly like Transparent here, a canvas having no depth buffer.

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

Fill color, or the wall's color for an outline.

Color color_end = Color(1, 1, 1, 1)

The far end of the gradient. Ignored unless color_mode is something other than Single.

GeomDash dash = null

Assign a GeomDash to dash this shape; leave empty for solid.

Vector2 end = Vector2(100, 0)

The other end, in the node's own space.

LineEndCap end_cap = Geom.CAP_ROUND

How the ends are finished: None, Square, or Round.

bool gradient = false

Run color to color_end along the line's length.

Vector2 start = Vector2(-100, 0)

One end, in the node's own space. Endpoints are positions, so they follow the node's transform in full.

float thickness = 8.0

How wide the line is drawn.

ThicknessSpace thickness_space = Geom.SPACE_METERS

Whether thickness is measured in canvas units or in pixels. Canvas units zoom with the view like ordinary 2D content; pixels hold their size on screen through a zoom, which is what a HUD wants. Either way the node's scale multiplies it.