Skip to content

Geolet

A lightweight Python library for drawing geometry problems using Asymptote.

Why Geolet?

Creating geometry diagrams for math handouts is painful:

  • GeoGebra requires manual export and fiddly positioning
  • Raw Asymptote code is verbose and low-level
  • TikZ/PGF has a steep learning curve

Geolet provides a high-level, Pythonic API that generates clean Asymptote code underneath.

Quick Example

"""Quick example showing Euler line construction."""

from geolet import autofigure, line, point, triangle


@autofigure
def quick_example():
    A = point(0, 0, "A", label_dir="SW")
    B = point(8, 0, "B", label_dir="SE")
    C = point(3, 6, "C", label_dir="N")

    T = triangle(A, B, C)

    H = T.orthocenter(label="H", label_dir="S", color="red")
    G = T.centroid(label="G", label_dir="S", color="blue")
    O = T.circumcenter(label="O", label_dir="S", color="green")

    euler = line(H, O, color="purple", style="dashed")

Generate output with the CLI:

geolet generate quick_example.py -o output/ -f svg

Quick Example

Features

  • Intuitive API: Create points, lines, circles, and triangles with simple function calls
  • Triangle Centers: Built-in support for orthocenter, centroid, circumcenter, incenter
  • Geometric Operations: Intersections, reflections, inversions, tangent lines
  • Automatic Layout: Smart label positioning with compass directions (N, NE, E, ...)
  • Multiple Outputs: Generate Asymptote source, PDF, or SVG

Installation

pip install geolet

Asymptote must be installed separately:

# Ubuntu/Debian
sudo apt install asymptote

# macOS
brew install asymptote