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:

from geolet import Point, Segment, autofigure


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

    # Connect them with segments
    Segment(A, B)
    Segment(B, C)
    Segment(C, A)

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("A", 0, 0)
    B = Point("B", 1, 0)
    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("A", 0, 0)
    B = Point("B", 1, 0)
    seg = Segment(A, B)

    return [A, B, seg]

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

Label Positioning

Labels are positioned using compass directions:

        N
    NW     NE
  W    •    E
    SW     SE
        S
Point("A", 0, 0, label_dir="NE")  # Label to the northeast
Point("B", 1, 0, label_dir="S")   # Label to the south

Styling

Most primitives accept styling parameters:

# Colors
Segment(A, B, color="red")
Circle(A, B, C, color="blue")

# Line styles
Line(A, B, style="dashed")
Segment(A, B, style="dotted")

# Line width
Segment(A, B, width=2.0)

Next Steps