Skip to content

Getting Started

Installation

1. Install Asymptote

Geolet uses Asymptote as its rendering backend. Install it first:

sudo apt install asymptote
brew install asymptote

Download from asymptote.sourceforge.io

Verify the installation:

asy --version

2. Install Geolet

pip install geolet

Or with uv:

uv add geolet

Your First Figure

Create a file called triangle.py:

"""Getting started triangle example."""

from geolet import autofigure, point, segment


@autofigure
def getting_started_triangle():
    # Create three points
    A = point(0, 0, "A", label_dir="SW")
    B = point(4, 0, "B", label_dir="SE")
    C = point(2, 3, "C", label_dir="N")

    # Connect them with segments
    ab = segment(A, B)
    bc = segment(B, C)
    ca = segment(C, A)

Your first triangle

Generate the output:

# Generate Asymptote source
geolet generate triangle.py

# Generate PDF directly
geolet generate triangle.py -f pdf

# Generate SVG
geolet generate triangle.py -f svg

Understanding Decorators

Geolet provides two decorators for creating figures:

@autofigure - Automatic Collection

The @autofigure decorator automatically collects all Drawable objects created in the function. No return statement needed.

@autofigure
def my_figure():
    A = point(0, 0, "A")
    B = point(1, 0, "B")
    segment(A, B)  # Automatically included

@figure - Explicit Return

The @figure decorator requires you to explicitly return a list of drawables:

@figure
def my_figure():
    A = point(0, 0, "A")
    B = point(1, 0, "B")
    seg = segment(A, B)

    return [A, B, seg]

Use @figure when you need more control over what gets drawn.

Next Steps