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

Refactor for demonstration #2

Merged
merged 88 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
5547fc4
Remove extras/
janbridley Jul 8, 2024
81b1a98
Remove pipfile
janbridley Jul 8, 2024
ce35689
Remove test notebook
janbridley Jul 8, 2024
3fedfed
Add .pre-commit-config.yaml
janbridley Jul 8, 2024
6004e0a
Lint files
janbridley Jul 8, 2024
890a856
Fix type or
janbridley Jul 8, 2024
ea9b66e
Update .gitignore
janbridley Jul 8, 2024
16ae71c
Fix type or
janbridley Jul 8, 2024
bbeeaaa
Add pyproject.toml
janbridley Jul 8, 2024
1b696c0
Update README.rst
janbridley Jul 8, 2024
d567e33
Add example image
janbridley Jul 8, 2024
6e600d3
Fix example image
janbridley Jul 8, 2024
d98bb23
Update README.md
janbridley Jul 8, 2024
d72409c
Update README.md
janbridley Jul 8, 2024
55e0bd1
Add svgs
janbridley Jul 8, 2024
15b0376
Update README.md
janbridley Jul 8, 2024
253f3ff
Update images in README.md
janbridley Jul 8, 2024
0eb84fb
Fix install
janbridley Jul 10, 2024
590e9ed
Normalize camera distance for preset views
janbridley Jul 10, 2024
24250b8
Update doc svgs
janbridley Oct 11, 2024
383aff8
Lint README.md
janbridley Oct 11, 2024
4828580
Decouple coxeter
janbridley Oct 11, 2024
b1b59ff
Clean up code
janbridley Oct 11, 2024
ba95094
Update type annotation
janbridley Oct 11, 2024
6350cbe
Fix example
janbridley Oct 11, 2024
49e2f7a
Update fill color for example
janbridley Oct 12, 2024
b7ac6c3
Clean up main file
janbridley Oct 12, 2024
2275ae3
Update example to render doc images
janbridley Oct 12, 2024
0a03548
Fix type annotation in svg3d
janbridley Oct 12, 2024
62b26de
Enable one-line if statements
janbridley Oct 12, 2024
17e1362
Add test for array padding
janbridley Oct 12, 2024
0c6b411
Update pre-commit config
janbridley Oct 12, 2024
602507e
Reenable E701
janbridley Oct 12, 2024
77f1b86
Add extensive test for view matrix
janbridley Oct 12, 2024
0518d53
Filter unreasonable arrays
janbridley Oct 12, 2024
c9e2039
Fix hypothesis flakiness
janbridley Oct 12, 2024
ac608ee
Disable too_low health check
janbridley Oct 13, 2024
36ac388
Test projection matrix
janbridley Oct 13, 2024
1a40725
Update README.md
janbridley Oct 13, 2024
1cb64b4
Update readme examples and code
janbridley Oct 13, 2024
5a9a33b
Replace ISOMETRIC view with exact matrix
janbridley Oct 13, 2024
7784dae
Test isometric view
janbridley Oct 13, 2024
a014ae3
Update trimetric
janbridley Oct 13, 2024
1d94054
Rerender example images
janbridley Oct 13, 2024
d5d8451
CLean up view class
janbridley Oct 13, 2024
9c29f21
Refactor to standard directory-based layour
janbridley Oct 13, 2024
b886645
Fix organization
janbridley Oct 13, 2024
8a66dcb
Update examples to use shaders
janbridley Oct 13, 2024
efc9f05
Correct isometric matrix
janbridley Oct 13, 2024
bcfe2ba
Fix isometric view
janbridley Oct 13, 2024
c6e5a68
Format code block
janbridley Oct 13, 2024
c988774
Update README to note shader
janbridley Oct 13, 2024
ce55b4b
Remove unused doc file
janbridley Oct 13, 2024
f6b473a
Update README.md
janbridley Oct 13, 2024
2eb6345
Update README.md
janbridley Oct 13, 2024
d81690a
Update README.md
janbridley Oct 13, 2024
8bfa6cb
Update README.md
janbridley Oct 13, 2024
43bf8da
Add teapot to README
janbridley Oct 13, 2024
eeb0631
Update teapot image
janbridley Oct 13, 2024
8ba4ada
Update README.md
janbridley Oct 13, 2024
cd8f3ca
Add stanford bunny example
janbridley Oct 14, 2024
66ad97b
Cache calculation of normals
janbridley Oct 14, 2024
53b14d3
Replace missing cache step
janbridley Oct 14, 2024
9576e6c
lfs-track svg
janbridley Oct 14, 2024
d128dbf
Update gitignore
janbridley Oct 14, 2024
1b50ba2
Add name to license
janbridley Oct 14, 2024
3ae7546
Add CI
janbridley Oct 14, 2024
b6bd8ff
Remove py3.9 from CI
janbridley Oct 14, 2024
afe73a7
Update macos runner config
janbridley Oct 14, 2024
cedc61c
Properly configure requirements files
janbridley Oct 14, 2024
df6e147
Remove unnecessary gitattributes
janbridley Oct 14, 2024
c51ed02
Add oloid example to README.md
janbridley Oct 14, 2024
91b8057
Fix link
janbridley Oct 14, 2024
8dbabdd
Add example to README.md
janbridley Oct 14, 2024
7159a05
Update README.md
janbridley Oct 14, 2024
7283343
Add citations to README header
janbridley Oct 14, 2024
93696c3
Add final examples to README.md
janbridley Oct 15, 2024
db7b0e6
Fix image formatting
janbridley Oct 15, 2024
a6bcb3b
Center div
janbridley Oct 15, 2024
88aa2ad
Update README.md
janbridley Oct 15, 2024
db9f6c9
Update README.md
janbridley Oct 15, 2024
d4b3b66
Add from_vertices_and_faces method
janbridley Oct 15, 2024
3a261c6
Update README example 2
janbridley Oct 15, 2024
7cfa76d
Fix readme rendered image
janbridley Oct 15, 2024
5b72419
Improve example2
janbridley Oct 15, 2024
7b9c9db
Fix sentence fragment
janbridley Oct 15, 2024
3916279
Fix line wrapping
janbridley Oct 15, 2024
2f2aef7
Standardize example code
janbridley Oct 15, 2024
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