Skip to content

Commit 1f14248

Browse files
committed
projection: Add flatten Option to Ortho
1 parent ec26b41 commit 1f14248

File tree

5 files changed

+10
-6
lines changed

5 files changed

+10
-6
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
- Fixed a bug with cetz creating invalid stroke objects for `stroke: none` (#1059).
2828
- Increased the rounding digits from 8 to 10, fixing some rounding bugs
2929
with `ortho`.
30+
- Added a `flatten: (bool)` argument to `ortho`, that allows setting all z
31+
components to zero.
3032

3133
# 0.4.2
3234
- The `tree` element now has a `anchor:` argument to position the tree (#929)

gallery/paciolis.png

779 Bytes
Loading

gallery/paciolis.typ

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import draw: *
88
let phi = (1 + calc.sqrt(5)) / 2
99

10-
ortho({
10+
ortho(flatten: true, {
1111
hide({
1212
line(
1313
(-phi, -1, 0), (-phi, 1, 0), (phi, 1, 0), (phi, -1, 0), close: true, name: "xy",
@@ -33,11 +33,11 @@
3333
line("a.0", (0, -phi, 1), "b.2")
3434

3535
anchor("A", (0, phi, 1))
36-
content("A", [$A$], anchor: "north", padding: .1)
36+
content("A", [$A$], anchor: "south", padding: .1)
3737
anchor("B", (-1, 0, phi))
38-
content("B", [$B$], anchor: "south", padding: .1)
38+
content("B", [$B$], anchor: "east", padding: .1)
3939
anchor("C", (1, 0, phi))
40-
content("C", [$C$], anchor: "south", padding: .1)
40+
content("C", [$C$], anchor: "north", padding: .1)
4141
line("A", "B", stroke: (dash: "dashed"))
4242
line("A", "C", stroke: (dash: "dashed"))
4343
})

gallery/plate-capacitor.png

91 Bytes
Loading

src/draw/projection.typ

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,14 @@
246246
/// - cull-face (none,str): Enable back-face culling if set to `"cw"` for clockwise
247247
/// or `"ccw"` for counter-clockwise. Polygons of the specified order will not get drawn.
248248
/// - reset-transform (bool): Ignore the current transformation matrix
249+
/// - flatten (bool): Set all z-components to 0.
249250
/// - body (element): Elements to draw
250-
#let ortho(x: 35.264deg, y: 45deg, z: 0deg, sorted: true, cull-face: none, reset-transform: false, body) = scope(ctx => {
251+
#let ortho(x: 35.264deg, y: 45deg, z: 0deg, sorted: true, cull-face: none, reset-transform: false, flatten: false, body) = scope(ctx => {
251252
_projection(body, ortho-matrix(x, y, z), ortho-projection-matrix,
252253
sorted: sorted,
253254
cull-face: cull-face,
254-
reset-transform: reset-transform)
255+
reset-transform: reset-transform,
256+
flatten: flatten)
255257
})
256258

257259
/// Draw elements on the xy-plane with optional z offset.

0 commit comments

Comments
 (0)