vecview 0.2.0__tar.gz → 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- vecview-0.4.0/AGENTS.md +212 -0
- vecview-0.4.0/CHANGELOG.md +392 -0
- {vecview-0.2.0 → vecview-0.4.0}/PKG-INFO +102 -37
- {vecview-0.2.0 → vecview-0.4.0}/README.md +99 -33
- vecview-0.4.0/docs/animation.md +293 -0
- {vecview-0.2.0 → vecview-0.4.0}/docs/cameras.md +115 -35
- {vecview-0.2.0 → vecview-0.4.0}/docs/development.md +56 -14
- {vecview-0.2.0 → vecview-0.4.0}/docs/embedding.md +46 -16
- vecview-0.4.0/docs/gallery/aharonov_bohm_ring.svg +51 -0
- vecview-0.4.0/docs/gallery/altermagnetic_dot.svg +378 -0
- vecview-0.4.0/docs/gallery/bloch_sphere.svg +281 -0
- vecview-0.4.0/docs/gallery/brillouin_zone.svg +291 -0
- vecview-0.4.0/docs/gallery/dirac_cone.svg +4170 -0
- vecview-0.4.0/docs/gallery/fullerene.svg +1340 -0
- vecview-0.4.0/docs/gallery/kitaev_chain.svg +441 -0
- vecview-0.4.0/docs/gallery/mirror_planes.svg +47 -0
- vecview-0.4.0/docs/gallery/perovskite.svg +90 -0
- vecview-0.4.0/docs/gallery/skyrmion.svg +4179 -0
- vecview-0.4.0/docs/gallery/slab_polarizer.svg +170 -0
- vecview-0.4.0/docs/gallery/solenoid.svg +1244 -0
- vecview-0.4.0/docs/gallery.md +164 -0
- vecview-0.4.0/docs/images/readme.svg +1 -0
- {vecview-0.2.0 → vecview-0.4.0}/docs/index.md +27 -20
- vecview-0.4.0/docs/outlines.md +134 -0
- vecview-0.4.0/docs/scenes.md +737 -0
- vecview-0.4.0/docs/shapes.md +409 -0
- vecview-0.4.0/examples/README.md +56 -0
- vecview-0.4.0/examples/__main__.py +70 -0
- vecview-0.4.0/examples/aharonov_bohm_ring.py +115 -0
- {vecview-0.2.0 → vecview-0.4.0}/examples/altermagnetic_dot.py +157 -127
- vecview-0.4.0/examples/bloch_sphere.py +175 -0
- {vecview-0.2.0/examples/gallery → vecview-0.4.0/examples}/brillouin_zone.py +65 -26
- vecview-0.4.0/examples/dirac_cone.py +150 -0
- {vecview-0.2.0/examples/gallery → vecview-0.4.0/examples}/fullerene.py +36 -39
- vecview-0.4.0/examples/kitaev_chain.py +370 -0
- {vecview-0.2.0/examples/gallery → vecview-0.4.0/examples}/mirror_planes.py +18 -19
- vecview-0.4.0/examples/pendulum.py +129 -0
- {vecview-0.2.0/examples/gallery → vecview-0.4.0/examples}/perovskite.py +42 -34
- vecview-0.4.0/examples/rotating_dipole.py +276 -0
- vecview-0.4.0/examples/skyrmion.py +85 -0
- {vecview-0.2.0 → vecview-0.4.0}/examples/slab_polarizer.py +153 -163
- {vecview-0.2.0/examples/gallery → vecview-0.4.0/examples}/solenoid.py +46 -21
- {vecview-0.2.0 → vecview-0.4.0}/pyproject.toml +2 -5
- {vecview-0.2.0 → vecview-0.4.0}/src/vecview/__init__.py +19 -3
- vecview-0.4.0/src/vecview/_animation_refs.py +119 -0
- vecview-0.4.0/src/vecview/_animation_svg.py +471 -0
- vecview-0.4.0/src/vecview/_canvas.py +785 -0
- vecview-0.4.0/src/vecview/_drawing.py +555 -0
- vecview-0.4.0/src/vecview/_elements.py +251 -0
- vecview-0.4.0/src/vecview/_numeric.py +30 -0
- {vecview-0.2.0 → vecview-0.4.0}/src/vecview/_occlusion.py +164 -60
- vecview-0.4.0/src/vecview/_place.py +184 -0
- vecview-0.4.0/src/vecview/_planar.py +169 -0
- vecview-0.4.0/src/vecview/_solid_drawing.py +414 -0
- vecview-0.4.0/src/vecview/_solids.py +735 -0
- vecview-0.4.0/src/vecview/_tracks.py +113 -0
- vecview-0.4.0/src/vecview/_transforms.py +60 -0
- vecview-0.4.0/src/vecview/_types.py +72 -0
- {vecview-0.2.0 → vecview-0.4.0}/src/vecview/_vec.py +28 -2
- vecview-0.4.0/src/vecview/animation.py +160 -0
- vecview-0.4.0/src/vecview/outlines.py +214 -0
- vecview-0.4.0/src/vecview/scene.py +344 -0
- {vecview-0.2.0 → vecview-0.4.0}/src/vecview/shapes.py +374 -81
- vecview-0.4.0/tests/test_animation.py +457 -0
- vecview-0.4.0/tests/test_arrows.py +155 -0
- {vecview-0.2.0 → vecview-0.4.0}/tests/test_document.py +44 -1
- {vecview-0.2.0 → vecview-0.4.0}/tests/test_occlusion.py +104 -41
- vecview-0.4.0/tests/test_outlines.py +267 -0
- {vecview-0.2.0 → vecview-0.4.0}/tests/test_package_metadata.py +27 -3
- vecview-0.4.0/tests/test_parts.py +278 -0
- vecview-0.4.0/tests/test_regions.py +137 -0
- {vecview-0.2.0 → vecview-0.4.0}/tests/test_scene.py +227 -8
- vecview-0.4.0/tests/test_shapes.py +868 -0
- {vecview-0.2.0 → vecview-0.4.0}/tests/test_solids.py +77 -5
- vecview-0.4.0/tests/test_tracked_scenes.py +116 -0
- {vecview-0.2.0 → vecview-0.4.0}/zensical.toml +2 -0
- vecview-0.2.0/AGENTS.md +0 -116
- vecview-0.2.0/CHANGELOG.md +0 -177
- vecview-0.2.0/docs/gallery/altermagnetic_dot.svg +0 -1
- vecview-0.2.0/docs/gallery/bloch_sphere.svg +0 -1
- vecview-0.2.0/docs/gallery/brillouin_zone.svg +0 -1
- vecview-0.2.0/docs/gallery/dirac_cone.svg +0 -1
- vecview-0.2.0/docs/gallery/fullerene.svg +0 -1
- vecview-0.2.0/docs/gallery/mirror_planes.svg +0 -1
- vecview-0.2.0/docs/gallery/perovskite.svg +0 -1
- vecview-0.2.0/docs/gallery/skyrmion.svg +0 -1
- vecview-0.2.0/docs/gallery/slab_polarizer.svg +0 -1
- vecview-0.2.0/docs/gallery/solenoid.svg +0 -1
- vecview-0.2.0/docs/gallery.md +0 -123
- vecview-0.2.0/docs/images/readme.svg +0 -1
- vecview-0.2.0/docs/scenes.md +0 -513
- vecview-0.2.0/docs/shapes.md +0 -255
- vecview-0.2.0/examples/gallery/__main__.py +0 -78
- vecview-0.2.0/examples/gallery/_common.py +0 -39
- vecview-0.2.0/examples/gallery/bloch_sphere.py +0 -126
- vecview-0.2.0/examples/gallery/dirac_cone.py +0 -93
- vecview-0.2.0/examples/gallery/skyrmion.py +0 -71
- vecview-0.2.0/src/vecview/_types.py +0 -31
- vecview-0.2.0/src/vecview/scene.py +0 -2427
- vecview-0.2.0/tests/test_shapes.py +0 -484
- {vecview-0.2.0 → vecview-0.4.0}/.gitignore +0 -0
- {vecview-0.2.0 → vecview-0.4.0}/LICENSE +0 -0
- {vecview-0.2.0 → vecview-0.4.0}/docs/readme_figure.py +0 -0
- {vecview-0.2.0 → vecview-0.4.0}/src/vecview/camera.py +0 -0
- {vecview-0.2.0 → vecview-0.4.0}/src/vecview/projections.py +0 -0
- {vecview-0.2.0 → vecview-0.4.0}/src/vecview/py.typed +0 -0
- {vecview-0.2.0 → vecview-0.4.0}/tests/test_camera.py +0 -0
- {vecview-0.2.0 → vecview-0.4.0}/tests/test_planes.py +0 -0
- {vecview-0.2.0 → vecview-0.4.0}/tests/test_projections.py +0 -0
vecview-0.4.0/AGENTS.md
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
# VecView contributor guide
|
|
2
|
+
|
|
3
|
+
## Scope
|
|
4
|
+
|
|
5
|
+
`vecview` projects world-space geometry into one SVG document, with an explicit
|
|
6
|
+
layer stack. It does not plot data, compile TeX, rasterize, export PDF, compose
|
|
7
|
+
multi-panel figures, or edit existing SVG.
|
|
8
|
+
|
|
9
|
+
The package is **independent and has no downstream dependencies**. Consumers
|
|
10
|
+
integrate through `Scene.to_svg_document()` alone; that direction is one-way.
|
|
11
|
+
Do not add a consumer-specific adapter, import, dependency, example, or test.
|
|
12
|
+
|
|
13
|
+
Naming the sibling projects is fine where it is only provenance: `vecview` is
|
|
14
|
+
developed alongside FigWorks and VecTeX as a suite, and a "Related projects"
|
|
15
|
+
link says so. What must stay out is *coupling* -- consumer-specific API
|
|
16
|
+
documentation, worked integration examples, or tests that import a consumer.
|
|
17
|
+
A tool that composes figures from `vecview` output documents that integration
|
|
18
|
+
on its own side.
|
|
19
|
+
|
|
20
|
+
## Architecture
|
|
21
|
+
|
|
22
|
+
- Keep the three-way split, and do not let it blur:
|
|
23
|
+
- `shapes.py` knows numbers only — world-space arrays and `Face` records. No
|
|
24
|
+
camera, no style, no SVG import.
|
|
25
|
+
- `outlines.py` builds 2D footprints and cross-sections. `Region(exterior,
|
|
26
|
+
holes)` explicitly distinguishes one connected region from a list of
|
|
27
|
+
disconnected regions. Plain point arrays remain shorthand for one boundary.
|
|
28
|
+
The private `_planar.py` centralizes planar validation, region reconstruction,
|
|
29
|
+
and clipping with Shapely; `shapes.py` delegates topology to it. Shapely is
|
|
30
|
+
also used by `outlines.py` and `_occlusion.py`, never exposed in the public API.
|
|
31
|
+
- `camera.py` defines what a camera *is*: `Camera` (the abstract contract) and
|
|
32
|
+
`ParallelCamera` (the affine machinery). Back-face culling lives here
|
|
33
|
+
because it is a camera question, not a scene one.
|
|
34
|
+
- `projections.py` holds the concrete projections: `OrthographicCamera` and
|
|
35
|
+
`ObliqueCamera`.
|
|
36
|
+
- Only the rendering modules build `svg` elements: `scene.py` and the
|
|
37
|
+
private `_elements.py`, `_canvas.py`, and `_solids.py`, and for animation
|
|
38
|
+
`_animation_svg.py` and `_animation_refs.py`. `_drawing.py` imports it only
|
|
39
|
+
to check what `slot` is given, and `_occlusion.py` only for a type.
|
|
40
|
+
`shapes.py`, `camera.py`, `projections.py`, `_place.py`,
|
|
41
|
+
`_solid_drawing.py`, `_planar.py`, `_tracks.py`, and `_transforms.py` never
|
|
42
|
+
do.
|
|
43
|
+
- `animation.py` samples a pure time-to-scene callback through the static
|
|
44
|
+
renderer and writes once what every frame draws alike. A scene holding tracks
|
|
45
|
+
is that callback underneath: a drawing call given a `Track` anywhere in its
|
|
46
|
+
arguments is kept as made (`_Tracked`, via `_trackable` in `_drawing.py`),
|
|
47
|
+
and `at(t)` replays it with the tracks read, sharing the calls without one.
|
|
48
|
+
A frame is drawn exactly as the same scene would be as a still; do not add an
|
|
49
|
+
animation-only rendering path. A new drawing call needs `@_trackable`.
|
|
50
|
+
- `_occlusion.py` is private: exact visibility for `sort_by_depth(layer)`.
|
|
51
|
+
The canvas describes each element of a sorted layer as a `Surface` (outline
|
|
52
|
+
plus a depth that goes on smoothly past its edge) or a `Line`, lazily, and
|
|
53
|
+
`resolve` clips and splits them. Keep closed-form depths closed-form.
|
|
54
|
+
Its shapely work is batched -- one tree query, then one vectorised call per
|
|
55
|
+
stage over every pair -- because per-call overhead, not GEOS, was most of the
|
|
56
|
+
time; keep new stages batched. Pairs keep the order the tree returns them in,
|
|
57
|
+
which fixes the order of everything built from them and so the output bytes.
|
|
58
|
+
- `_vec.py` and `_types.py` are private. Re-export from `__init__.py` what should
|
|
59
|
+
be public; `unit` is the only helper promoted so far.
|
|
60
|
+
- Geometry that needs a camera to be computed does not belong in `shapes.py`.
|
|
61
|
+
- Angles are degrees at every public boundary, radians nowhere.
|
|
62
|
+
- Keep the camera hierarchy honest. `Camera` promises only `project`, `at`,
|
|
63
|
+
`depth`, and `visible`. `direction`, `screen_basis`, `foreshortening`, and
|
|
64
|
+
`plane_matrix` belong on `ParallelCamera` because each assumes a screen offset
|
|
65
|
+
independent of position. Moving any of them up would make them a silent wrong
|
|
66
|
+
answer for a perspective camera, which would subclass `Camera` directly.
|
|
67
|
+
- `Scene.plane` reserves a group and nothing more. This package must not parse,
|
|
68
|
+
normalize, or embed foreign SVG; a consumer fills the group by id.
|
|
69
|
+
- `Scene.slot` may hold an svg.py element passed as `content`, placed as given
|
|
70
|
+
in the aligned box and never parsed, copied, or rewritten. That is the one
|
|
71
|
+
way content from elsewhere -- a VecTeX label -- goes into a scene without a
|
|
72
|
+
consumer; anything that would need VecView to read or change it does not.
|
|
73
|
+
A written document lays its tags out one per line, so whitespace may fall
|
|
74
|
+
between the content's tags, which SVG ignores; never inside `<text>` or
|
|
75
|
+
`<foreignObject>`, where it would render.
|
|
76
|
+
- `Scene` records objects and nothing else; it never projects. Every public
|
|
77
|
+
drawing method validates what it can without a camera and appends one record.
|
|
78
|
+
The canvas holds a camera and implements each method of the same name;
|
|
79
|
+
rendering replays the record onto a fresh canvas. Camera-dependent work and
|
|
80
|
+
errors belong in the canvas, and a canvas never records, so its methods may
|
|
81
|
+
call each other freely. `_Canvas` (`_canvas.py`) has the layer stack, exact
|
|
82
|
+
visibility, and the flat calls; `_SolidCanvas` (`_solids.py`) adds the curved
|
|
83
|
+
solids and is the canvas a render uses. `_elements.py` holds the SVG emission
|
|
84
|
+
helpers both share.
|
|
85
|
+
- The world-space drawing calls live on private bases, split as the canvases
|
|
86
|
+
are: `_Drawing` (`_drawing.py`) has the flat calls and the recording and
|
|
87
|
+
track replay; `_SolidDrawing` (`_solid_drawing.py`, with `Part`) adds the
|
|
88
|
+
curved solids and is what `Scene` and `Part` derive from. `Scene` adds what
|
|
89
|
+
only makes sense for a whole document: cameras, rendering, `sort_by_depth` (a
|
|
90
|
+
property of the layer stack), `<defs>`, raw elements, and screen-space calls.
|
|
91
|
+
Keep a call off the drawing bases unless it has a world position, because a
|
|
92
|
+
part must be able to move everything it holds.
|
|
93
|
+
- `place` copies a part's recorded calls with their geometry moved by a `_Frame`
|
|
94
|
+
(`_place.py`).
|
|
95
|
+
`_MOVES` says, per call, which arguments are points, directions, edges, or
|
|
96
|
+
lengths. A new world-space call needs an entry there, or placing it fails with
|
|
97
|
+
a `KeyError`; `tests/test_parts.py` places one of every call.
|
|
98
|
+
|
|
99
|
+
## Module size
|
|
100
|
+
|
|
101
|
+
- No Python file in the repository exceeds **1000 lines**, pylint's default
|
|
102
|
+
`max-module-lines` (C0302). `tests/test_package_metadata.py` enforces it.
|
|
103
|
+
- Aim for a few hundred lines. When a module nears the limit, split it before
|
|
104
|
+
adding to it, along a real seam of responsibility -- emission, visibility,
|
|
105
|
+
solids -- not into arbitrary halves, and keep the output byte-identical: a
|
|
106
|
+
split moves code, it does not change it.
|
|
107
|
+
|
|
108
|
+
## Deliberate non-features
|
|
109
|
+
|
|
110
|
+
Do not add these without the user changing the design first:
|
|
111
|
+
|
|
112
|
+
- **Automatic depth sorting across layers** (a z-buffer, or sorting a layer that
|
|
113
|
+
did not ask). Layers are the model. A beam crossing a translucent slab has
|
|
114
|
+
three parts that no automatic depth rule orders correctly. Depth only ever
|
|
115
|
+
acts inside a layer passed to `Scene.sort_by_depth`, and there it is exact
|
|
116
|
+
visibility by clipping -- there is no painter's-algorithm mode, so do not add
|
|
117
|
+
geometry workarounds for one (cutting solids into pieces so they sort).
|
|
118
|
+
- **Rasterizing or PDF export.** Runtime dependencies stay `numpy`, `svg.py`,
|
|
119
|
+
`shapely`, and `contourpy`; a test in `tests/test_package_metadata.py`
|
|
120
|
+
enforces it. The last two are required because robust polygon clipping and
|
|
121
|
+
sub-pixel contours -- exact visibility, booleans on outlines -- are not worth
|
|
122
|
+
reimplementing. There are no runtime extras.
|
|
123
|
+
- **Shading, materials, or lighting models.** This draws schematics, not renders.
|
|
124
|
+
`highlight=` gradients are a fill style fixed on screen, with no light
|
|
125
|
+
direction; keep them that way.
|
|
126
|
+
|
|
127
|
+
## Development
|
|
128
|
+
|
|
129
|
+
- Supported Python: 3.12 and newer.
|
|
130
|
+
- `uv sync --all-extras` for a full environment.
|
|
131
|
+
- Run `uv run ruff format --check .`, `uv run ruff check .`, `uv run ty check`,
|
|
132
|
+
and `uv run pytest` before reporting a change complete.
|
|
133
|
+
- Typing serves the code, not the other way round. Type public signatures and
|
|
134
|
+
what types naturally, and keep `ty check` passing; where precise types would
|
|
135
|
+
contort the code -- a decorator that changes what a parameter accepts, say --
|
|
136
|
+
use a looser annotation or a targeted `# ty: ignore[code]`. Do not raise the
|
|
137
|
+
Python floor for typing features.
|
|
138
|
+
- Run `uv run python examples/slab_polarizer.py --projection all`,
|
|
139
|
+
`uv run python examples/altermagnetic_dot.py --projection all`, and
|
|
140
|
+
`uv run python examples` after touching geometry or projection, and
|
|
141
|
+
look at `examples/out/*.png` after touching a solid, an outline, or
|
|
142
|
+
the depth sort. Refresh `docs/gallery/` with `--docs` when a figure changes. It is the realistic end-to-end check, and it renders
|
|
143
|
+
pictures whose correctness is visible. Mirrored or upside-down content, or a
|
|
144
|
+
beam that misses the slab, is the usual symptom of a projection bug.
|
|
145
|
+
- Keep output deterministic: layer ties resolve by insertion order, coordinates
|
|
146
|
+
are rounded on emission. Byte-identical output is what keeps a figure diffable.
|
|
147
|
+
|
|
148
|
+
## Examples
|
|
149
|
+
|
|
150
|
+
The examples -- `examples/*.py`, `examples/README.md`, and `docs/readme_figure.py`
|
|
151
|
+
-- are the showcase. People read them to learn the library, so they must read as
|
|
152
|
+
the obvious way to draw the figure, not as a record of how it was first got to
|
|
153
|
+
work.
|
|
154
|
+
|
|
155
|
+
- After adding a public function or parameter, go through every example and use
|
|
156
|
+
it wherever it makes the code shorter or clearer, in the same piece of work.
|
|
157
|
+
A helper an example wrote for itself that the library now provides is
|
|
158
|
+
deleted, not kept beside the new call.
|
|
159
|
+
- Prefer the library's vocabulary to hand-rolled geometry: `extrude` over axis
|
|
160
|
+
permutations, `place` over copy-pasted blocks, `cull=True` over
|
|
161
|
+
`cam.visible`, `class_` for kinds of objects.
|
|
162
|
+
- Name things for what they are in the figure (`gate`, `contact`, `beam`), keep
|
|
163
|
+
each function to one part of the picture, and comment the physics or the
|
|
164
|
+
design decision, not the Python.
|
|
165
|
+
- A simplification must not change the picture: check the rendered PNGs, and
|
|
166
|
+
say so if an id or a pixel changed on purpose.
|
|
167
|
+
|
|
168
|
+
## Testing
|
|
169
|
+
|
|
170
|
+
- Test geometry as numbers, not as rendered strings: winding against declared
|
|
171
|
+
normal, a wave against an exact sine, a circle's radius. Reserve
|
|
172
|
+
rendered-output assertions for document structure.
|
|
173
|
+
- Add a regression test for every projection or winding bug — a wrong normal is
|
|
174
|
+
invisible until it culls the wrong wall.
|
|
175
|
+
- Test a projection through `foreshortening()`, not through its construction
|
|
176
|
+
angles: the ratios are what the axonometric classification is defined by.
|
|
177
|
+
- Rendering under a camera must stay byte-identical to building the scene with
|
|
178
|
+
that camera from the start. The parametrized test in `tests/test_scene.py`
|
|
179
|
+
covers all five projections.
|
|
180
|
+
- `tests/test_document.py` pins what a consumer relies on: a parseable
|
|
181
|
+
standalone document, a viewBox agreeing with `width`/`height`, geometry inside
|
|
182
|
+
it, and deterministic bytes. It must not import a consumer.
|
|
183
|
+
|
|
184
|
+
## Documentation
|
|
185
|
+
|
|
186
|
+
Documentation is part of every change, not a follow-up. A change is not complete,
|
|
187
|
+
and must not be committed, until the documentation agrees with it.
|
|
188
|
+
|
|
189
|
+
- Every user-visible change -- a new call or parameter, a changed default or
|
|
190
|
+
behaviour, a new error, a renamed id -- updates, in the same commit: the
|
|
191
|
+
docstrings, the relevant page in `docs/`, `README.md` wherever it summarizes
|
|
192
|
+
the feature, and `CHANGELOG.md` (Keep a Changelog 1.1.0).
|
|
193
|
+
- Documentation states what the code does, checked against the code: every
|
|
194
|
+
signature, default, generated id, and error matches the source, and every
|
|
195
|
+
runnable snippet runs. Do not document intentions or planned features.
|
|
196
|
+
- When a change makes a passage elsewhere wrong, fix that passage in the same
|
|
197
|
+
commit, even on a page the change did not otherwise touch.
|
|
198
|
+
- When a figure's output changes, refresh `docs/gallery/` with
|
|
199
|
+
`uv run python examples --docs`, and `docs/images/` with
|
|
200
|
+
`uv run python docs/readme_figure.py`.
|
|
201
|
+
- Run `uv run zensical build` and confirm it reports no issues before reporting
|
|
202
|
+
the change complete.
|
|
203
|
+
|
|
204
|
+
## Naming and packaging
|
|
205
|
+
|
|
206
|
+
- **`vecview` is the distribution and import name**, published on PyPI since
|
|
207
|
+
0.2.0. See `docs/development.md` for the rename procedure, should it ever be
|
|
208
|
+
needed.
|
|
209
|
+
- `pyproject.toml` is canonical for Python metadata.
|
|
210
|
+
- Do not commit, tag, upload, or publish unless the user explicitly asks.
|
|
211
|
+
- Before 1.0, make API changes directly: update consumers, tests, and docs in the
|
|
212
|
+
same change. No compatibility aliases or deprecated wrappers.
|
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here, following
|
|
4
|
+
[Keep a Changelog 1.1.0](https://keepachangelog.com/en/1.1.0/).
|
|
5
|
+
|
|
6
|
+
## [Unreleased]
|
|
7
|
+
|
|
8
|
+
## [0.4.0] - 2026-10-16
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- `path_arrow_shape(path, normal, shaft_w, head_w, head_len)`: a flat arrow
|
|
13
|
+
that follows a path in a plane, its shaft mitred at every vertex and its head
|
|
14
|
+
on the last `head_len` of the path. A two-point path gives exactly
|
|
15
|
+
`arrow_shape`; a path that leaves its plane, folds the shaft, or turns back
|
|
16
|
+
raises `ValueError`.
|
|
17
|
+
- `annulus(center, r_in, r_out, n, *, theta0_deg=0)`: a ring footprint,
|
|
18
|
+
`Region(outer, [inner])`, for washers, microrings, and loops. `annulus_sector`
|
|
19
|
+
keeps returning one outline, and a full turn raises, pointing to `annulus`.
|
|
20
|
+
- Written documents credit VecView. `Scene.to_svg_document()`, `Scene.save()`
|
|
21
|
+
and the `Animation` equivalents add a Dublin Core `<metadata>` block naming
|
|
22
|
+
"VecView vX, https://github.com/maiani/vecview" as the creator, after any
|
|
23
|
+
`<defs>`. `render()` still returns the drawing alone.
|
|
24
|
+
- Written documents put one tag per line, indented, so a regenerated figure's
|
|
25
|
+
diff shows what changed instead of one changed line. `<text>` and
|
|
26
|
+
`<foreignObject>` elements stay whole, where whitespace would render, and the
|
|
27
|
+
markup is otherwise unchanged: every example renders pixel-identically.
|
|
28
|
+
- `Region(exterior, holes=())` explicitly represents one connected planar
|
|
29
|
+
region. Disconnected components are lists of regions, not lists of rings.
|
|
30
|
+
The record copies coordinates into read-only arrays; `rings` exposes its boundaries.
|
|
31
|
+
`prism_faces`, `extrude`, and `Scene.polygon` accept regions or plain point arrays;
|
|
32
|
+
`Scene.polygon` refuses holes off the outline's plane, outside it, or crossing.
|
|
33
|
+
- `Face.holes` and `Face.region` expose interior boundaries. Holed faces render
|
|
34
|
+
as even-odd paths, with correct coverage in depth-sorted layers. Placement,
|
|
35
|
+
animation, edge drawing, and seamless walls preserve their boundaries.
|
|
36
|
+
- `examples/aharonov_bohm_ring.py`: a ring and its leads as one shape with a
|
|
37
|
+
hole, threaded by a flux, in the gallery.
|
|
38
|
+
|
|
39
|
+
### Changed
|
|
40
|
+
|
|
41
|
+
- Outline booleans always return `list[Region]`; offsets and films return
|
|
42
|
+
one `Region`. `to_plane` lifts arrays to arrays and regions to regions.
|
|
43
|
+
Ambiguous lists of bare rings are rejected.
|
|
44
|
+
- A holed extrusion lists its hole walls first, then caps and outer walls, so
|
|
45
|
+
`faces(..., cull=True)` paints a hole's far side under the cap: exact for one
|
|
46
|
+
convex hole and for shallow multi-hole plates; deep or non-convex ones need a
|
|
47
|
+
sorted layer. `prism_walls` draws the hole walls as a path of their own,
|
|
48
|
+
`"{id}-holes"`, before the outer walls, so their stroke stays hidden too. Pick
|
|
49
|
+
the cap by name. Hole-free extrusions keep their order. Hole walls are named
|
|
50
|
+
`"hole{k}_side-{i}"`, so a drawn one's id reads `plate-hole0_sidem3`; edge
|
|
51
|
+
indices still follow the supplied boundaries.
|
|
52
|
+
- Planar validation and clipping share a private Shapely backend. Input holes
|
|
53
|
+
must be separated from the exterior and one another; point-touching holes
|
|
54
|
+
produced by booleans are also rejected. `trim_corners` rejects holed faces.
|
|
55
|
+
- A depth-sorted layer emits far fewer clip paths. An unstroked flat polygon
|
|
56
|
+
that is partly hidden is redrawn as its visible part -- one `<path>` with the
|
|
57
|
+
same id, classes, and style -- instead of a `<polygon>` with a
|
|
58
|
+
`{id}-visible` clip path. A surface whose fill shows whole is no longer
|
|
59
|
+
clipped where only its stroke's overhang runs under a nearer surface, so a
|
|
60
|
+
stroked mesh seen from where it does not fold over itself gains no clip paths
|
|
61
|
+
at all: a 45 x 45 stroked height field goes from 1774 clip paths and 1.09 MB
|
|
62
|
+
to none and 0.26 MB. Where surfaces cross, half a stroke's width may now lie
|
|
63
|
+
over the nearer one along the edge they meet at.
|
|
64
|
+
|
|
65
|
+
### Fixed
|
|
66
|
+
|
|
67
|
+
- `cylinder(..., ends=False)` and `cone(..., end=False)` no longer stroke the
|
|
68
|
+
elliptical rims of the open ends. A stroked open tube is now the unstroked
|
|
69
|
+
body `{id}-body` and its two sides as a separate `{id}-edge` path, so a beam
|
|
70
|
+
of light is outlined along its length only. A sliced open cylinder strokes
|
|
71
|
+
no end arc either.
|
|
72
|
+
- The shapes docs gave a wall's id as `wire-side-3`; it is `wire-sidem3`.
|
|
73
|
+
- `cut` along the plane of one of the solid's own faces no longer keeps that face
|
|
74
|
+
and adds a cap over it, doubling the cut: the face is dropped and the cap takes
|
|
75
|
+
its place. A face with an edge lying in the plane -- the top of a U cut along
|
|
76
|
+
its inner wall -- is clipped ring by ring instead of folding back on itself,
|
|
77
|
+
so the solid closes up with the right volume.
|
|
78
|
+
- `sphere`, `cylinder`, `cone`, and `arrow3d` accept `stroke_linejoin`,
|
|
79
|
+
`stroke_linecap`, and `stroke_miterlimit` instead of raising `TypeError`.
|
|
80
|
+
They apply to the outline paths; circles and ellipses -- spheres and end
|
|
81
|
+
disks -- have no corners or ends, so they are left off there.
|
|
82
|
+
- Seamless hole walls now traverse connected edges regardless of input winding.
|
|
83
|
+
- Every face uses region-aware half-space clipping, including simple concave
|
|
84
|
+
faces. Repeated cuts can open holes and split faces into disconnected pieces
|
|
85
|
+
without emitting self-intersecting cap polygons.
|
|
86
|
+
|
|
87
|
+
## [0.3.0] - 2026-10-08
|
|
88
|
+
|
|
89
|
+
Animation is new in this release, and its API may still change before 1.0.
|
|
90
|
+
|
|
91
|
+
### Added
|
|
92
|
+
|
|
93
|
+
- `slot(..., content=element)` -- a slot can hold an svg.py element instead of
|
|
94
|
+
waiting for a consumer to fill it: the element, `w` by `h` in its own
|
|
95
|
+
coordinates from its top-left, is placed with its box aligned on the anchor,
|
|
96
|
+
and follows every camera. VecView places it as given, never parsing, copying,
|
|
97
|
+
or changing it. The examples with mathematical labels now typeset them with
|
|
98
|
+
VecTeX and hold them in slots, in place of `svg.TSpan` subscripts.
|
|
99
|
+
- `Animation(scene, *, duration, view_box, fps=30, repeat=1, background=None)`
|
|
100
|
+
-- a scene that moves, sampled at evenly spaced times, rendered by the
|
|
101
|
+
static renderer, and written as one standalone SVG that plays itself with
|
|
102
|
+
native SVG timing. Any argument of any drawing call may be a `Track`, inside
|
|
103
|
+
lists and style keywords too; `place` takes a track of parts, for what
|
|
104
|
+
changes in number, and the active camera may be a track. A call holding a
|
|
105
|
+
track is checked at `t = 0` and kept as made; `Scene.at(t)` and `Part.at(t)`
|
|
106
|
+
give the drawing as it stands at `t`, and a scene with tracks renders as it
|
|
107
|
+
stands at `t = 0`. `Animation` also takes a pure function from seconds to a
|
|
108
|
+
whole `Scene`. Finite playback holds the exact
|
|
109
|
+
frame at `duration`; `repeat=None` loops. What every frame draws alike --
|
|
110
|
+
identical definitions, and the elements every frame draws in the same paint
|
|
111
|
+
order, wherever they fall -- is written once, in place, with its own ids.
|
|
112
|
+
Each stretch that changes is one `<use>` whose `href` steps through its
|
|
113
|
+
distinct contents with discrete timing, each written once in `<defs>` with
|
|
114
|
+
its ids renamed `frame{i}-{id}` (the original kept as `data-vecview-id`);
|
|
115
|
+
a stretch is cut at layer boundaries and per element wherever that is
|
|
116
|
+
estimated to be smaller, a lone element is its own target, and an animation
|
|
117
|
+
that never changes is a static document. `animation.breakdown()` says where
|
|
118
|
+
the file's bytes go, stretch by stretch.
|
|
119
|
+
- `vecview.animation`: `Track` with `keyframes` and `map`, the interpolators
|
|
120
|
+
`linear` (numbers and 3D points) and `hold`, the easing `smoothstep`, and
|
|
121
|
+
`rotate` and `scale`, which copy a part turned or scaled about a pivot and
|
|
122
|
+
take tracks too.
|
|
123
|
+
- `examples/pendulum.py` -- a pendulum swinging through one seamless period,
|
|
124
|
+
with its equations typeset by VecTeX. See `docs/animation.md`.
|
|
125
|
+
- `examples/rotating_dipole.py` -- a rotating electric dipole and the exact
|
|
126
|
+
retarded field it radiates: `E` as arrows and `B_z` as spiral shading over
|
|
127
|
+
the equatorial plane, through one seamless period.
|
|
128
|
+
|
|
129
|
+
- `class_=` on every drawing call that takes style keywords: one string,
|
|
130
|
+
space-separated, or a sequence of names. An id names one object, a class a
|
|
131
|
+
kind of object -- every gate, every oxygen -- for a stylesheet, a selector in
|
|
132
|
+
the composing tool, or Inkscape to reach together. Each top-level element a
|
|
133
|
+
call emits carries the classes (every face, both strokes of an edge set, every
|
|
134
|
+
slice of a sliced solid, both parts of a line a depth-sorted layer splits) and the
|
|
135
|
+
elements inside a solid's group do not, so a selector matches each object
|
|
136
|
+
once. Names that are not strings raise `TypeError` at the call.
|
|
137
|
+
- `Part` and `place` -- objects drawn once, in their own coordinates, and
|
|
138
|
+
placed any number of times: `place(layer, part, at=, rotate=(axis, deg),
|
|
139
|
+
mirror=, scale=, id=, class_=)`. Only rigid motions and a uniform scale, so
|
|
140
|
+
every solid keeps its exact outline; faces stay wound to their normals under a
|
|
141
|
+
mirror. The placement's layer is added to the part's layers, `id` prefixes
|
|
142
|
+
every id in the part, `class_` is added to its classes, and parts nest. A
|
|
143
|
+
part holds only world-space calls: no camera, `<defs>`, screen-space calls, or
|
|
144
|
+
depth sorting, which stay the scene's.
|
|
145
|
+
- `extrude(section, along)` -- a planar cross-section in any plane swept along
|
|
146
|
+
any vector, as correctly wound `Face`s named `"start"`, `"end"`, and
|
|
147
|
+
`"side-{i}"`. Wall `i` is built on section edge `i` as given, in either
|
|
148
|
+
winding, so walls can be picked out by edge. `prism_faces` is now the
|
|
149
|
+
special case along `z`, with unchanged output.
|
|
150
|
+
- `vecview.outlines` -- footprints and cross-sections built in 2D: `rect`,
|
|
151
|
+
`regular`, `offset`, `film` (a layer of given thickness deposited on a run of
|
|
152
|
+
edges, numbered as `extrude` numbers walls), `union`, `difference`,
|
|
153
|
+
`intersection`, and `to_plane` to lift an outline into 3D. Results are
|
|
154
|
+
counter-clockwise and ordered deterministically; a result with a hole
|
|
155
|
+
raises `ValueError` rather than dropping it.
|
|
156
|
+
- `cut(faces, origin, normal)` -- a closed solid cut open by a plane, for a
|
|
157
|
+
cutaway: faces are clipped and keep their names, and the cut is capped by
|
|
158
|
+
faces named `"cut"` (or `"cut-0"`, ...) lying in the plane, so a section can
|
|
159
|
+
be styled apart. Non-convex solids work; a cap with a hole raises.
|
|
160
|
+
- `examples/kitaev_chain.py` -- a minimal Kitaev chain after Dvir et
|
|
161
|
+
al., Nature 614, 445 (2023): a gated InSb nanowire running past draped Cr/Au
|
|
162
|
+
contacts, a grounded Al shell of finite thickness that continues onto the
|
|
163
|
+
dielectric, and a Majorana mode on each dot.
|
|
164
|
+
- A documentation page for `vecview.outlines`.
|
|
165
|
+
|
|
166
|
+
### Changed
|
|
167
|
+
|
|
168
|
+
- Depth-sorted layers render faster, with byte-identical output: exact
|
|
169
|
+
visibility makes its shapely calls in batches -- one tree query, and one
|
|
170
|
+
vectorised intersection for every overlapping pair -- and orders the painting
|
|
171
|
+
of clipped surfaces with a heap. The Dirac cone renders in 0.61 of the time,
|
|
172
|
+
the solenoid in 0.79.
|
|
173
|
+
- The examples are self-contained scripts side by side in `examples/`, each
|
|
174
|
+
writing its own SVG to `examples/out`; `examples/gallery/` and the shared
|
|
175
|
+
`_common.py` are gone. `python examples` builds them all, with timings and
|
|
176
|
+
PNG previews, and `--docs` still refreshes `docs/gallery/`.
|
|
177
|
+
- `sort_by_depth(layer)` always decides visibility exactly, point by point:
|
|
178
|
+
surfaces are clipped where an opaque surface hides them, lines are split, and
|
|
179
|
+
a surface hidden entirely is dropped. The painter's algorithm keyed on each
|
|
180
|
+
element's mean depth is gone, and with it the need to cut geometry so it
|
|
181
|
+
sorts: a coil wraps an unsliced core. A sorted layer renders in up to a few
|
|
182
|
+
seconds and can double in size, from its clip paths.
|
|
183
|
+
- `shapely` and `contourpy` are required dependencies, alongside `numpy` and
|
|
184
|
+
`svg.py`, and the `occlusion` extra is gone: exact visibility always works,
|
|
185
|
+
and robust polygon clipping is needed beyond it, for booleans on outlines.
|
|
186
|
+
Both still load only when first needed.
|
|
187
|
+
- An unsliced cylinder or cone names its end disks `{id}-end0` and `{id}-end1`
|
|
188
|
+
and its highlight gradient `{id}-shade`, as a sliced one already did, instead
|
|
189
|
+
of `{id}-body-end0` and `{id}-body-shade`. Slicing no longer renames what a
|
|
190
|
+
consumer selects.
|
|
191
|
+
- Rendering raises `ValueError` when two elements share an id, naming every
|
|
192
|
+
id used more than once. Duplicate ids are invalid SVG, and a consumer
|
|
193
|
+
selecting by id -- or a `url(#...)` fill -- would silently reach the wrong
|
|
194
|
+
element. Ids a call derives (`slab-pz`, `{id}-body`, `{id}-profile`) are
|
|
195
|
+
checked too, so a hand-written id that collides with one is caught.
|
|
196
|
+
- Every example is rewritten with the new API -- `Part` and `place` for
|
|
197
|
+
repeated and mirrored objects, `extrude` and `outlines` for cross-sections,
|
|
198
|
+
`class_` for every kind of object -- and reads as the obvious way to draw its
|
|
199
|
+
figure. The pictures are unchanged apart from the depth-sorted ones.
|
|
200
|
+
- The documentation is checked against the code, page by page: wrong
|
|
201
|
+
signatures, ids, and claims fixed, every runnable snippet run, and the
|
|
202
|
+
missing public API documented.
|
|
203
|
+
|
|
204
|
+
### Removed
|
|
205
|
+
|
|
206
|
+
- `sort_by_depth(..., exact=True)`: every sorted layer is exact now, so the
|
|
207
|
+
keyword is gone and passing it raises `TypeError`.
|
|
208
|
+
|
|
209
|
+
### Fixed
|
|
210
|
+
|
|
211
|
+
- Text is escaped: a label holding `<`, `>`, or `&` -- `"B < 0"`, `"Smith &
|
|
212
|
+
Jones"` -- made the document unreadable, because svg.py writes text as it is
|
|
213
|
+
given. `text`, `text2d`, and their `svg.TSpan` runs are escaped now, the
|
|
214
|
+
runs copied rather than changed.
|
|
215
|
+
- `double_arrow_shape` clamps a `head_len` longer than half the arrow, as
|
|
216
|
+
`arrow_shape` already did, instead of returning a self-crossing polygon.
|
|
217
|
+
- `Scene.is_empty` is true exactly when rendering would find nothing to fit a
|
|
218
|
+
viewBox to. A scene holding only `add`, or `rect2d` and `text2d` with
|
|
219
|
+
`grow=False`, was reported non-empty and then failed to render.
|
|
220
|
+
- The background `<rect>` takes the viewBox's rounded numbers, so it covers
|
|
221
|
+
the viewBox exactly and no longer carries full-precision floats.
|
|
222
|
+
|
|
223
|
+
## [0.2.0] - 2026-10-06
|
|
224
|
+
|
|
225
|
+
### Added
|
|
226
|
+
|
|
227
|
+
- PyPI release workflow: validate the tag, run CI, build and check distributions,
|
|
228
|
+
then publish with Trusted Publishing.
|
|
229
|
+
|
|
230
|
+
- `Scene.sort_by_depth(layer)` -- opt one layer in to the painter's algorithm.
|
|
231
|
+
Its world-space elements are drawn back to front, keyed by the mean depth of
|
|
232
|
+
the points that made them; ties keep insertion order and screen-space
|
|
233
|
+
elements go on top. Other layers are untouched, and `with_camera` re-sorts.
|
|
234
|
+
- `Scene.sphere` -- the exact outline of a sphere as one `<circle>`, or a rotated
|
|
235
|
+
`<ellipse>` under an oblique camera.
|
|
236
|
+
- `Scene.cylinder` and `Scene.cone` -- exact outlines of a cylinder, frustum, or
|
|
237
|
+
cone: two straight sides and two elliptical arcs in one `<path>`, plus the end
|
|
238
|
+
disk that faces the camera. `slices=n` cuts a long cylinder into separately
|
|
239
|
+
sorted lengths that still draw as one seamless solid.
|
|
240
|
+
- `Scene.arrow3d` -- a solid arrow, cylindrical shaft and conical head in one group.
|
|
241
|
+
- `Scene.tube` -- a tube along a world-space curve, as overlapping stroked pieces
|
|
242
|
+
that sort over and under each other without seams.
|
|
243
|
+
- `highlight=` on the solids -- a gradient fill lightest toward the upper left;
|
|
244
|
+
spheres of one colour pair share one gradient.
|
|
245
|
+
- `Scene.edges` -- the edges of a convex solid, visible ones solid and hidden ones
|
|
246
|
+
dropped or restyled (dashed), optionally one path per edge and trimmed at the
|
|
247
|
+
vertices.
|
|
248
|
+
- `Scene.sphere_curve` -- a curve on a sphere, split exactly where it passes behind.
|
|
249
|
+
- `sort_by_depth(layer, exact=True)` -- exact visibility, with the new
|
|
250
|
+
`occlusion` extra (`shapely`, `contourpy`). Every surface keeps its native
|
|
251
|
+
element, clipped to what no opaque surface hides: exactly between planes, and
|
|
252
|
+
to a sub-pixel contour of the closed-form depths where a sphere, cylinder,
|
|
253
|
+
cone, arrow, or tube is involved. Lines are split where they pass behind a
|
|
254
|
+
surface, and the hidden part dropped or drawn in a `back` style. Opaque
|
|
255
|
+
surfaces are painted so that what hides another comes after it.
|
|
256
|
+
- `Scene.polyline(..., back=...)` -- the style of the parts an exact layer hides.
|
|
257
|
+
- `Scene._repr_svg_`, so a scene displays inline in Jupyter.
|
|
258
|
+
- `text` and `text2d` accept a list of `svg.TSpan` runs, for subscripts.
|
|
259
|
+
- `arc_shape`, `helix`, `surface_faces`, `convex_polyhedron`, and `trim_corners`.
|
|
260
|
+
- `examples/gallery/` -- a perovskite cell, the fcc Brillouin zone, C60, the Bloch
|
|
261
|
+
sphere, a gapped Dirac cone, a Néel skyrmion, a solenoid, and crossing mirror
|
|
262
|
+
planes in an exact layer, each from one
|
|
263
|
+
script; `python examples/gallery --docs` builds them all into the new Gallery
|
|
264
|
+
page.
|
|
265
|
+
|
|
266
|
+
### Changed
|
|
267
|
+
|
|
268
|
+
- Use ty for type checking in development and CI instead of mypy.
|
|
269
|
+
- **A scene holds objects and cameras; a camera renders them.** Drawing calls
|
|
270
|
+
only record, and nothing is projected until `render`, `save`, `bbox`, or
|
|
271
|
+
`to_svg_document`. As in a 3D application, `scene.cameras` holds named
|
|
272
|
+
cameras and `scene.camera` is the active one (formerly `scene.cam`), set by
|
|
273
|
+
name or directly; the zero-argument `to_svg_document` uses it.
|
|
274
|
+
`Scene(camera=None, *, cameras=None, pad, background)`, and `render(camera=None,
|
|
275
|
+
*, pad, background)`, `save(path, camera=None)`, and `bbox(camera=None)` take a
|
|
276
|
+
camera or a name. `with_camera` returns a copy with a different active camera.
|
|
277
|
+
Output is byte-identical to before.
|
|
278
|
+
- Errors that need no camera -- a self-crossing footprint, a one-point tube, a
|
|
279
|
+
highlight without a fill -- still raise at the call; those that need one -- a
|
|
280
|
+
plane seen edge-on, an arrow along the projection ray -- raise on render.
|
|
281
|
+
- `Scene.items` and `Scene.defs` are gone; they belonged to one projection, and
|
|
282
|
+
now live on the private canvas a render builds.
|
|
283
|
+
- `prism_walls` builds its path through the shared helper; output is unchanged.
|
|
284
|
+
|
|
285
|
+
## [0.1.2] - 2026-10-05
|
|
286
|
+
|
|
287
|
+
### Added
|
|
288
|
+
|
|
289
|
+
- `examples/altermagnetic_dot.py`: a device sketch of an altermagnetic quantum
|
|
290
|
+
dot -- arc-shaped non-convex gates and tapered leads through `prism_walls`,
|
|
291
|
+
Gaussian spin densities, camera-facing spins, a bias circuit, and labels at
|
|
292
|
+
world points -- built once and replayed under four projections with
|
|
293
|
+
`with_camera`.
|
|
294
|
+
|
|
295
|
+
## [0.1.1] - 2026-10-05
|
|
296
|
+
|
|
297
|
+
### Changed
|
|
298
|
+
|
|
299
|
+
- Prose spells the project VecView; the distribution, import, and command names
|
|
300
|
+
stay `vecview`. The sibling projects are now FigWorks (formerly FigForge) and
|
|
301
|
+
VecWire (formerly cirquit).
|
|
302
|
+
|
|
303
|
+
## [0.1.0] - 2026-10-05
|
|
304
|
+
|
|
305
|
+
### Added
|
|
306
|
+
|
|
307
|
+
- `Scene.slot(layer, pt3, w, h, *, id, align, dx, dy)` — reserve an empty,
|
|
308
|
+
screen-aligned group pinned to a projected world point, for upright content
|
|
309
|
+
such as TeX labels. The group is translated to the anchor and records `align`
|
|
310
|
+
as `data-align`; a `w` × `h` box grows the fitted viewBox. The anchor is
|
|
311
|
+
reprojected by `with_camera`, which a hand-placed `rect2d` was not.
|
|
312
|
+
- `Scene.silhouette(layer, solid)` — fill the projected convex hull of a solid as
|
|
313
|
+
one polygon. Drawn in the wall colour under the cap, it replaces per-wall
|
|
314
|
+
polygons and the hairline seams between them.
|
|
315
|
+
- `Scene.arrow(..., normal="camera")` — an arrow turned about its axis to show
|
|
316
|
+
its widest face, resolved at draw time so a reprojection turns it too. Also
|
|
317
|
+
accepts an explicit normal.
|
|
318
|
+
- `Scene.gaussian(layer, center, u, v, a, b, *, id, color)` — a soft Gaussian spot
|
|
319
|
+
lying in a world plane, as one polygon filled by a radial gradient mapped
|
|
320
|
+
through the plane's affine transform.
|
|
321
|
+
- `prism_faces(footprint, z0, z1)` — any simple footprint, convex or not, extruded
|
|
322
|
+
along `z`, as correctly wound `Face`s that cull like a box. Self-intersecting
|
|
323
|
+
or self-touching outlines raise `ValueError`.
|
|
324
|
+
- `Scene.prism_walls(layer, footprint, z0, z1)` — the camera-facing walls of an
|
|
325
|
+
extrusion as one seamless `<path>`, one strip per run of consecutive facing
|
|
326
|
+
walls. With the cap drawn over it, exact at any height for unstroked walls,
|
|
327
|
+
including non-convex footprints.
|
|
328
|
+
- `annulus_sector(center, r_in, r_out, theta0_deg, theta1_deg, n)` — the
|
|
329
|
+
counter-clockwise footprint of an annular sector or pie wedge.
|
|
330
|
+
- `ellipse_shape(center, u, v, a, b, n)` — the generalization of `circle_shape`.
|
|
331
|
+
- `Camera` is now an abstract base holding only the projection contract
|
|
332
|
+
(`project`, `at`, `depth`, `visible`), with `ParallelCamera` beneath it for the
|
|
333
|
+
affine machinery (`direction`, `screen_basis`, `foreshortening`,
|
|
334
|
+
`plane_matrix`). A future perspective camera would subclass `Camera` directly
|
|
335
|
+
and inherit none of the affine methods, which is the point of the split.
|
|
336
|
+
- `OrthographicCamera` — the axonometric camera, aimed by azimuth and elevation,
|
|
337
|
+
with `isometric()` and `dimetric(ratio=...)` constructors, plus `axonometry()`
|
|
338
|
+
to classify a projection from its actual ratios.
|
|
339
|
+
- `ObliqueCamera` — cavalier and cabinet projections, which no azimuth and
|
|
340
|
+
elevation can reproduce.
|
|
341
|
+
- `Camera.foreshortening()` — the screen length of each unit world axis.
|
|
342
|
+
- `Scene.with_camera(cam)` — re-render a finished scene under another projection.
|
|
343
|
+
Recorded world-space calls are replayed, giving output byte-identical to
|
|
344
|
+
building from scratch with that camera.
|
|
345
|
+
- `Scene.faces(..., cull=True)` — cull back faces at draw time rather than in the
|
|
346
|
+
caller, so a reprojection selects the right walls instead of keeping the
|
|
347
|
+
original camera's.
|
|
348
|
+
- `Camera.plane_matrix()` and `Scene.plane()` — embed flat SVG content in a world
|
|
349
|
+
plane. Exact rather than approximate: a parallel projection restricted to a
|
|
350
|
+
plane is affine, which is what an SVG `matrix` expresses.
|
|
351
|
+
- Initial package, extracted from a single-module `vecview.py` used to draw an
|
|
352
|
+
altermagnetic-slab polarizer schematic.
|
|
353
|
+
- `Camera.screen_basis(normal)` — the in-plane world directions that move a point
|
|
354
|
+
purely right and purely down on screen, for any plane. Replaces a hand-rolled
|
|
355
|
+
2×2 solve in the caller.
|
|
356
|
+
- `Camera.visible(faces)` and `Camera.faces_camera(normal)` — back-face culling
|
|
357
|
+
by outward normal, replacing hand-listed wall corner pairs and a comment about
|
|
358
|
+
which octant the camera occupies.
|
|
359
|
+
- `Camera.direction(vec)` — projects a displacement, ignoring `origin`.
|
|
360
|
+
- `Camera.depth(pts)` — signed distance along the view axis, for callers that want
|
|
361
|
+
to order something by depth themselves.
|
|
362
|
+
- `box_faces(center, size)` and the `Face` record (`name`, `points`, `normal`) —
|
|
363
|
+
an axis-aligned box as six named, correctly wound faces.
|
|
364
|
+
- `in_plane_dir(angle_deg, u, v)` — unit direction at an angle within a plane.
|
|
365
|
+
- `Scene.faces(layer, faces, **style)` — draw a group of faces with one style. An
|
|
366
|
+
`id` is suffixed per face (`slab` → `slab-pz`, `slab-px`, …) rather than
|
|
367
|
+
repeated, since duplicate ids are invalid SVG.
|
|
368
|
+
- `Scene.to_svg_document()` — a complete SVG document string, the whole surface a
|
|
369
|
+
consumer needs to place a scene without importing this package.
|
|
370
|
+
- `Scene.save(path)`, `Scene.is_empty`, and `repr` for `Camera` and `Scene`.
|
|
371
|
+
- `Scene(cam, pad=..., background=...)` constructor defaults, so
|
|
372
|
+
`to_svg_document()` needs no arguments.
|
|
373
|
+
- Public `unit(v)`.
|
|
374
|
+
- Type hints throughout, checked with `mypy --strict`, and a `py.typed` marker.
|
|
375
|
+
- Documentation, and a test suite covering projection, geometry, layering, and
|
|
376
|
+
the document contract.
|
|
377
|
+
|
|
378
|
+
### Changed
|
|
379
|
+
|
|
380
|
+
- Coordinates that round to `-0.0` are written as `0.0`.
|
|
381
|
+
- **Python 3.12 is now the floor.** This drops the split where ruff targeted 3.11
|
|
382
|
+
while mypy targeted 3.12 to parse numpy 2's PEP 695 stubs, and lets the private
|
|
383
|
+
type aliases use `type` statements.
|
|
384
|
+
- Rename the distribution and import package from `svg3d` to `vecview`.
|
|
385
|
+
- Polygon and polyline coordinates are emitted as `svg.Point` pairs
|
|
386
|
+
(`points="1.5,2.25 3,-4"`) rather than a flat coordinate run.
|
|
387
|
+
- Rendering an empty scene now raises `ValueError` instead of producing a
|
|
388
|
+
document with a degenerate viewBox.
|
|
389
|
+
- `rect_shape` normalizes its axes, so an unnormalized direction no longer
|
|
390
|
+
silently stretches the rectangle.
|
|
391
|
+
- `circle_shape` derives its in-plane basis from the shared helper, making the
|
|
392
|
+
seam position consistent with other in-plane geometry.
|