Skip to main content

A pure-Python library for rendering professional CS graphics.

Project description

Tesserax: A Lightweight SVG Rendering Library

Tesserax is a modern Python 3.12 library designed for programmatic SVG generation with a focus on ease of use, layout management, and flexible geometric primitives. It is particularly well-suited for visualizing data structures, algorithms, and technical diagrams.

Key Features

  • Declarative Layouts: Effortlessly arrange shapes in Row or Column containers with automatic alignment and spacing.
  • Anchor System: Connect shapes using semantic anchors like top, bottom, left, right, and center.
  • Context Manager Support: Use with statements to group shapes naturally within the code.
  • Smart Canvas: Automatically fit the canvas viewport to the content with adjustable padding.
  • Rich Primitives: Includes Rect, Square, Circle, Ellipse, Line, Arrow, and Path.

Installation

pip install tesserax

Quick Start

The following example demonstrates how to create two shapes in a row and connect them with an arrow using the anchor system.

from tesserax import Canvas, Rect, Arrow, Circle
from tesserax.layout import Row

# Initialize a canvas
with Canvas() as canvas:
    # Arrange a circle and a rectangle in a row with a 50px gap
    with Row(gap=50):
        circle = Circle(20, fill="lightblue")
        rect = Rect(40, 40, fill="lightgrey")

    # Draw an arrow between the two shapes using anchors
    # .dx() provides a small offset for better visual spacing
    Arrow(
        circle.anchor("right").dx(5),
        rect.anchor("left").dx(-5)
    )

# Fit the viewport to the shapes and save
canvas.fit(padding=10).save("example.svg")

Core Components

1. Primitives

All shapes support standard SVG attributes like stroke and fill.

  • Rect & Square: Defined by width/height or a single size.
  • Circle & Ellipse: Defined by radii.
  • Arrow: A specialized line that automatically includes an arrowhead marker.
  • Path: Supports a fluent API for complex paths using move_to, line_to, cubic_to, and close.

2. Layouts

Layouts automate the positioning of child elements:

  • Row: Aligns shapes horizontally. Baselines can be set to start, middle, or end.
  • Column: Aligns shapes vertically with start, middle, or end alignment.

3. Transforms

Every shape has a Transform object allowing for:

  • Translation: shape.translated(dx, dy).
  • Rotation: shape.rotated(degrees).
  • Scaling: shape.scaled(factor).

Developer Information

Tesserax is built with modern Python 3.12 features, including:

  • Fully Typed: Comprehensive type hinting for better IDE support and safety.
  • Deep Integration: Utilizes dataclasses for points and transforms and abc for extensible shape definitions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tesserax-0.2.0.tar.gz (28.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tesserax-0.2.0-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file tesserax-0.2.0.tar.gz.

File metadata

  • Download URL: tesserax-0.2.0.tar.gz
  • Upload date:
  • Size: 28.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for tesserax-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d2cfe9d8204087826b72f50dac9604c184345c73cafc6144dbeb90612ae8d222
MD5 b7d30e0c2afa528d358c588229f131a3
BLAKE2b-256 6a7ea7f8dc0d180c4fb8bac5346f7cf048d4f6952d6e2fdff23b5dcd03d6763f

See more details on using hashes here.

File details

Details for the file tesserax-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: tesserax-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for tesserax-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7b1e7613ad32f82bf2cdc7179a53ec588d9e1013631914265b21dca9aad127f6
MD5 46b58e93b494a2e705c3b65447ce8d73
BLAKE2b-256 eee7630ace8051e998d2bc7f3d09818d36d9e6ab36e3938c4290f5c72fa20951

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page