geom

Languages

GDScript, C# and other GDExtensions.

geom is a GDExtension, so its classes are in ClassDB and every language Godot supports can access them.

Nodes

GeomDisc2D, GeomRect2D, GeomSphere and the rest are ordinary scene nodes and work regardless of language. Add one to your scene, set its properties in the Inspector, and it draws.

GDScript

The GeomDraw singleton and the enums are globals, and an enum name works as a type:

extends Node2D

func _process(_delta: float) -> void:
	GeomDraw.reset_all_draw_states()

	# Sizes and modes are named constants on Geom, not bare integers.
	GeomDraw.thickness_space = Geom.SPACE_VIEWPORT_PIXELS
	GeomDraw.thickness = 6.0
	GeomDraw.blend_mode = Geom.BLEND_ADDITIVE
	GeomDraw.disc_2d_colored(Vector2(100, 100), 40.0, Color(0.42, 0.85, 1.0))

	# The enum name is a type.
	var mode: Geom.BlendMode = Geom.BlendMode.BLEND_TRANSPARENT
	GeomDraw.blend_mode = mode
	GeomDraw.ring_2d_colored(Vector2(220, 100), 40.0, Color(1.0, 0.78, 0.36))

	# Any language can read the constants by name through ClassDB.
	var additive: int = ClassDB.class_get_integer_constant("Geom", "BLEND_ADDITIVE")
	GeomDraw.blend_mode = additive
	GeomDraw.disc_2d_colored(Vector2(340, 100), 40.0, Color(0.55, 0.98, 0.78))

languages

C#

Godot does not generate C# bindings for a GDExtension. The addon includes addons/geom/cs/Geom.cs, which wraps the singleton and declares the enums as C# enums. Godot.NET.Sdk compiles every .cs under the project, including under addons/, so there is nothing to set up.

using Godot;

Geom.Draw.ResetAllDrawStates();
Geom.Draw.ThicknessSpace = Geom.ThicknessSpace.ViewportPixels;
Geom.Draw.Thickness = 6f;
Geom.Draw.BlendMode = Geom.BlendMode.Additive;
Geom.Draw.Disc2DColored(new Vector2(100, 100), 40f, Colors.Cyan);

Enum names don’t need prefixes in C#: Geom.BlendMode.Additive, not BLEND_ADDITIVE.

An extension class cannot be constructed with new from C#, so nodes come from factories. Their properties go through Set and Get:

var disc = Geom.Nodes.Disc2D();
disc.Set("radius", 40f);
AddChild(disc);

Bulk Calls

Every call from C# boxes its arguments into Variants and looks the method up by name. A thousand discs:

one call per shapeone bulk call
GDScript114µs71µs
C#936µs90µs

Per shape, C# is eight times slower than GDScript. A bulk call crosses once for the whole batch, which is ten times faster from C# and level with GDScript.

var centers = new Vector2[4000];
// ... fill centers ...
Geom.Draw.Discs2D(centers, new float[] { 2f }, new Color[] { Colors.Cyan });

From C#, use the bulk calls wherever you can.

Other GDExtensions

There are no bindings for other languages. A Rust or C++ extension reaches geom through ClassDB:

let mut draw = Engine::singleton().get_singleton("GeomDraw").unwrap();
draw.call("disc_2d", &[Vector2::new(100.0, 100.0).to_variant(), 40.0.to_variant()]);

Constants are readable by name through ClassDB.class_get_integer_constant("Geom", "BLEND_ADDITIVE"), as the GDScript example above shows.

Summary

Nodes in the editorTyped drawing APITyped enumsFast bulk drawing
GDScriptyesyesyesyes
C#yesyes, via the shipped shimyes, as C# enumsyes
Other GDExtensionsyesno, dynamic callsby name lookupyes