Skip to main content

VecGL

CI

VecGL is a 3D rendering engine with vector output. It is inspired by OpenGL with the key difference that the rendering result is a set of points, lines, and triangles - not a pixelated image. These geometric primitives can be used to generate vector graphics or to drive pen plotters.

Getting started

The VecGL package is available through pip.

$ python3 -m pip install vecgl

Let's create and render a simple model. Here's the complete example for a sphere.

from math import pi

from vecgl.export import write_svg
from vecgl.linalg import (get_frustum_mat4, get_rotate_x_mat4,
                          get_rotate_y_mat4, get_translate_mat4, mul_mat4)
from vecgl.modellib import get_sphere_model
from vecgl.rendering import render
from vecgl.viewer import perspective_update_fn, show, show_interactively

# Get a predefined sphere model and choose nice colors.
# The sphere will span from -1.0 to 1.0 in all dimensions.
sphere = get_sphere_model(16, 32, "lightblue", "black")

# Look at the model interactively.
show_interactively(sphere, perspective_update_fn())

# Define the view and the projection transforms.
view_mat4 = mul_mat4(
    get_translate_mat4(0.0, 0.0, -2.0),
    get_rotate_x_mat4(-0.2 * pi),
    get_rotate_y_mat4(0.15 * pi),
)
projection_mat4 = get_frustum_mat4(-1.0, 1.0, -1.0, 1.0, 1.0, 100.0)

# Transform our sphere model and bring it to the clip space.
transform_mat4 = mul_mat4(projection_mat4, view_mat4)
sphere_in_ndc = sphere.transform(transform_mat4)

# Render, display, and export the model.
rendered = render(sphere_in_ndc)
show(rendered)
write_svg(rendered, "sphere.svg")

# You can access the vector-based rendering result through the rendered model.
for ln in rendered.lines:
    print(ln)

VecGL will render and display the sphere and print the vector-based rendering result to stdout.

This is an image

Build and run tests

Clone the repository.

$ git clone git@github.com:frgossen/vecgl.git
$ cd vecgl

Create a virtual environment and activate it (recommended).

$ python3 -m venv .venv
$ source .venv/bin/activate

Install all requirements in the virtual environment.

$ python3 -m pip install -r requirements.txt

Install the vecgl package in editable mode. This makes the package (and your changes) available when running the tests.

$ python3 -m pip install --editable .

You're all set for contributing back to the project. Run the tests with ...

$ python3 -m pytest --benchmark-skip

... and the benchmarks with ...

$ python3 -m pytest --benchmark-only

Metadata

Release files for vecgl 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vecgl 0.0.5
File Size Uploaded Provenance Actions
vecgl-0.0.5.tar.gz 46.8 kB Without provenance Details for vecgl-0.0.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for vecgl 0.0.5
File Interpreter ABI Platform Actions
vecgl-0.0.5-py3-none-any.whl Python 3 none any Details for vecgl-0.0.5-py3-none-any.whl

Total release size: 63.3 kB

Release files / vecgl-0.0.5.tar.gz

Download URL vecgl-0.0.5.tar.gz
Size 46.8 kB
Tags Source
SHA-256 checksum
How to use checksums
9d87055e1121a479d15e24ade07f7ae57295578ea42a33275982d70e336aa0d1
BLAKE2b-256 checksum
How to use checksums
5f6cc9f651a81f78e8c5761c7cf101ac1da20ab77908ee3786c04450ba6becdc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.1

Release files / vecgl-0.0.5-py3-none-any.whl

Download URL vecgl-0.0.5-py3-none-any.whl
Size 16.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e40dc324f8ab9b095b4971befe4e4f2de5c374a6bd707688b0630a3be58bc099
BLAKE2b-256 checksum
How to use checksums
61569977a3a7e32b5d518d91c6462f76da8e1c8d3f26a2f7127e4a9bb157935f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.1

Security for vecgl 0.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page