vecgl


Namevecgl JSON
Version 0.0.5 PyPI version JSON
download
home_page
SummaryVecGL is a 3D rendering engine with vector output
upload_time2023-02-03 06:51:29
maintainer
docs_urlNone
author
requires_python>=3.7
licenseCopyright 2022 Frederik Gossen Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords rendering rendering engine 3d engine vector graphics graphics library 3d
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # VecGL

[![CI](https://github.com/frgossen/vecgl/actions/workflows/ci.yml/badge.svg)](https://github.com/frgossen/vecgl/actions/workflows/ci.yml)

__*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](https://www.generativehut.com/post/axidraw).

## 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.

```py
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](./sphere.svg)

## 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 ...

```sh
$ python3 -m pytest --benchmark-only
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "vecgl",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "rendering,rendering engine,3D engine,vector graphics,graphics library,3D",
    "author": "",
    "author_email": "Frederik Gossen <frederik.gossen@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/5f/6c/c9f651a81f78e8c5761c7cf101ac1da20ab77908ee3786c04450ba6becdc/vecgl-0.0.5.tar.gz",
    "platform": null,
    "description": "# VecGL\n\n[![CI](https://github.com/frgossen/vecgl/actions/workflows/ci.yml/badge.svg)](https://github.com/frgossen/vecgl/actions/workflows/ci.yml)\n\n__*VecGL* is a 3D rendering engine with vector output.__\nIt is inspired by OpenGL with the key difference that the rendering result is a\nset of points, lines, and triangles - not a pixelated image. These geometric\nprimitives can be used to generate vector graphics or to drive\n[pen plotters](https://www.generativehut.com/post/axidraw).\n\n## Getting started\n\nThe VecGL package is available through `pip`.\n\n```\n$ python3 -m pip install vecgl\n```\n\nLet's create and render a simple model.\nHere's the complete example for a sphere.\n\n```py\nfrom math import pi\n\nfrom vecgl.export import write_svg\nfrom vecgl.linalg import (get_frustum_mat4, get_rotate_x_mat4,\n                          get_rotate_y_mat4, get_translate_mat4, mul_mat4)\nfrom vecgl.modellib import get_sphere_model\nfrom vecgl.rendering import render\nfrom vecgl.viewer import perspective_update_fn, show, show_interactively\n\n# Get a predefined sphere model and choose nice colors.\n# The sphere will span from -1.0 to 1.0 in all dimensions.\nsphere = get_sphere_model(16, 32, \"lightblue\", \"black\")\n\n# Look at the model interactively.\nshow_interactively(sphere, perspective_update_fn())\n\n# Define the view and the projection transforms.\nview_mat4 = mul_mat4(\n    get_translate_mat4(0.0, 0.0, -2.0),\n    get_rotate_x_mat4(-0.2 * pi),\n    get_rotate_y_mat4(0.15 * pi),\n)\nprojection_mat4 = get_frustum_mat4(-1.0, 1.0, -1.0, 1.0, 1.0, 100.0)\n\n# Transform our sphere model and bring it to the clip space.\ntransform_mat4 = mul_mat4(projection_mat4, view_mat4)\nsphere_in_ndc = sphere.transform(transform_mat4)\n\n# Render, display, and export the model.\nrendered = render(sphere_in_ndc)\nshow(rendered)\nwrite_svg(rendered, \"sphere.svg\")\n\n# You can access the vector-based rendering result through the rendered model.\nfor ln in rendered.lines:\n    print(ln)\n```\n\nVecGL will render and display the sphere and print the vector-based rendering\nresult to stdout.\n\n![This is an image](./sphere.svg)\n\n## Build and run tests\n\nClone the repository.\n\n```\n$ git clone git@github.com:frgossen/vecgl.git\n$ cd vecgl\n```\n\nCreate a virtual environment and activate it (recommended).\n\n```\n$ python3 -m venv .venv\n$ source .venv/bin/activate\n```\n\nInstall all requirements in the virtual environment.\n\n```\n$ python3 -m pip install -r requirements.txt\n```\n\nInstall the `vecgl` package in editable mode.\nThis makes the package (and your changes) available when running the tests.\n\n```\n$ python3 -m pip install --editable .\n```\n\nYou're all set for contributing back to the project.\nRun the tests with ...\n\n```\n$ python3 -m pytest --benchmark-skip\n```\n\n... and the benchmarks with ...\n\n```sh\n$ python3 -m pytest --benchmark-only\n```\n",
    "bugtrack_url": null,
    "license": "Copyright 2022 Frederik Gossen  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  ",
    "summary": "VecGL is a 3D rendering engine with vector output",
    "version": "0.0.5",
    "split_keywords": [
        "rendering",
        "rendering engine",
        "3d engine",
        "vector graphics",
        "graphics library",
        "3d"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "61569977a3a7e32b5d518d91c6462f76da8e1c8d3f26a2f7127e4a9bb157935f",
                "md5": "20f50165928ab3eeeb0ac57c80ce4367",
                "sha256": "e40dc324f8ab9b095b4971befe4e4f2de5c374a6bd707688b0630a3be58bc099"
            },
            "downloads": -1,
            "filename": "vecgl-0.0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "20f50165928ab3eeeb0ac57c80ce4367",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 16488,
            "upload_time": "2023-02-03T06:51:28",
            "upload_time_iso_8601": "2023-02-03T06:51:28.074894Z",
            "url": "https://files.pythonhosted.org/packages/61/56/9977a3a7e32b5d518d91c6462f76da8e1c8d3f26a2f7127e4a9bb157935f/vecgl-0.0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5f6cc9f651a81f78e8c5761c7cf101ac1da20ab77908ee3786c04450ba6becdc",
                "md5": "4785a095d6d8c43ac7502babb6696b1f",
                "sha256": "9d87055e1121a479d15e24ade07f7ae57295578ea42a33275982d70e336aa0d1"
            },
            "downloads": -1,
            "filename": "vecgl-0.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "4785a095d6d8c43ac7502babb6696b1f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 46824,
            "upload_time": "2023-02-03T06:51:29",
            "upload_time_iso_8601": "2023-02-03T06:51:29.640781Z",
            "url": "https://files.pythonhosted.org/packages/5f/6c/c9f651a81f78e8c5761c7cf101ac1da20ab77908ee3786c04450ba6becdc/vecgl-0.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-02-03 06:51:29",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "vecgl"
}
        
Elapsed time: 0.04253s