Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up deprecated functions. #2

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
*.svg
*.png
*.pxd
__pycache__
# Packaging and distribution
*.egg
*.egg-info*
*.whl
dist
build

# Compiled files
__pycache__/
*.pyc
*.out

# Development tooling
.hypothesis/
.ipynb_checkpoints/
.pytest_cache/
.ruff_cache/
28 changes: 28 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
ci:
autoupdate_schedule: quarterly

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 'v4.4.0'
hooks:
- id: end-of-file-fixer
exclude: tests/sample_data
- id: trailing-whitespace
exclude: tests/sample_data
- id: check-builtin-literals
- id: check-executables-have-shebangs
- id: check-json
- id: check-yaml
- id: debug-statements
- id: requirements-txt-fixer
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.6
hooks:
# Run the linter.
- id: ruff
types_or: [ python, pyi, jupyter ]
args: [ --fix ]
# Run the formatter.
- id: ruff-format
types_or: [ python, pyi, jupyter ]
15 changes: 0 additions & 15 deletions Pipfile

This file was deleted.

132 changes: 0 additions & 132 deletions Pipfile.lock

This file was deleted.

46 changes: 45 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ This is a single-file Python library for generating 3D wireframes in SVG format.
For a description of how the library was initially designed and implemented, check out
[this blog post](https://prideout.net/blog/svg_wireframes/#using-the-api).

## Installation

```bash

# Clone the repository
git clone https://github.com/janbridley/svg3d.git
cd svg3d

# Install to your python environment!
python -m pip install .

```

## Usage example (ConvexPolyhedron)
```python
from coxeter.families import ArchimedeanFamily
Expand Down Expand Up @@ -50,17 +63,48 @@ truncated_cube = ArchimedeanFamily.get_shape("Truncated Cube")
generate_svg(filename="truncated_cube.svg", poly=truncated_cube)
```

Running the code above generates the following image:

![Output for the first example.](doc/svgs/truncated_cube.svg)

And that's all it takes! For an even simpler startup, use one of the built in viewports.

For example:

```python
import svg3d

scene = [svg3d.Mesh.from_poly(poly, style=style)]

style = dict(
fill="#00B2A6",
fill_opacity="0.85",
stroke="black",
stroke_linejoin="round",
stroke_width="0.005",
)

scene = [
svg3d.Mesh.from_poly(
poly=ArchimedeanFamily.get_shape("Truncated Cube"),
style=style
)
]

# Convenience views: isometric, dimetric, and trimetric
iso = svg3d.View.isometric(scene, fov=1.0)
dim = svg3d.View.dimetric(scene, fov=1.0)
tri = svg3d.View.trimetric(scene, fov=1.0)


for view, view_type in zip([iso, dim, tri], ["iso", "dim", "tri"]):

svg3d.Engine([view]).render(f"{view_type}.svg")



```

| Isometric | Dimetric | Trimetric |
|-----------|----------|-----------|
| ![Isometric Image](doc/svgs/iso.svg) | ![Dimetric Image](doc/svgs/dim.svg) | ![Trimetric Image](doc/svgs/tri.svg) |

2 changes: 2 additions & 0 deletions doc/svgs/dim.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions doc/svgs/iso.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions doc/svgs/tri.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions doc/svgs/truncated_cube.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 7 additions & 7 deletions example.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ def generate_svg(filename, poly):
svg3d.Engine([view]).render(filename)


style = dict(
fill="#00B2A6",
fill_opacity="0.85",
stroke="black",
stroke_linejoin="round",
stroke_width="0.005",
)
style = {
"fill": "#00B2A6",
"fill_opacity": "0.85",
"stroke": "black",
"stroke_linejoin": "round",
"stroke_width": "0.005",
}

truncated_cube = ArchimedeanFamily.get_shape("Truncated Cube")
generate_svg(filename="truncated_cube.svg", poly=truncated_cube)
26 changes: 0 additions & 26 deletions extras/gallery.html

This file was deleted.

36 changes: 0 additions & 36 deletions extras/octasphere.html

This file was deleted.

Loading