Skip to content

Commit 5426e5f

Browse files
authored
fletcher:0.2.0 (#262)
1 parent 8450b18 commit 5426e5f

File tree

17 files changed

+3068
-0
lines changed

17 files changed

+3068
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Joseph Wilson
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Fletcher
2+
3+
_(noun) a maker of arrows_
4+
5+
[![Manual](https://img.shields.io/badge/docs-manual.pdf-blue)](https://github.com/Jollywatt/typst-fletcher/raw/v0.2.0/docs/manual.pdf)
6+
![Version](https://img.shields.io/badge/version-0.2.0-blue)
7+
8+
A [Typst]("https://typst.app/") package for drawing diagrams with arrows,
9+
built on top of [CeTZ]("https://github.com/johannes-wolf/cetz").
10+
11+
<picture>
12+
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/Jollywatt/typst-fletcher/raw/master/docs/examples/example-2.svg">
13+
<img alt="logo" width="600" src="https://github.com/Jollywatt/typst-fletcher/raw/master/docs/examples/example-1.svg">
14+
</picture>
15+
16+
```typ
17+
#fletcher.diagram(cell-size: 15mm, {
18+
let (src, img, quo) = ((0, 1), (1, 1), (0, 0))
19+
node(src, $G$)
20+
node(img, $im f$)
21+
node(quo, $G slash ker(f)$)
22+
edge(src, img, $f$, "->")
23+
edge(quo, img, $tilde(f)$, "hook-->", label-side: right)
24+
edge(src, quo, $pi$, "->>")
25+
})
26+
27+
#fletcher.diagram(
28+
node-stroke: black,
29+
node-fill: blue.lighten(90%),
30+
node((0,0), `typst`),
31+
node((1,0), "A"),
32+
node((2,0), "B", stroke: 2pt),
33+
node((2,1), "C"),
34+
35+
edge((0,0), (1,0), "->", bend: 15deg),
36+
edge((0,0), (1,0), "<-", bend: -15deg),
37+
edge((1,0), (2,1), "=>", bend: 20deg),
38+
edge((1,0), (2,0), "..>", bend: -0deg),
39+
)
40+
```
41+
42+
## Todo
43+
44+
- [x] Mathematical arrow styles
45+
- [ ] Support CeTZ arrowheads
46+
- [ ] Allow referring to node coordinates by their content
47+
- [ ] Support loops connecting a node to itself
48+
- [ ] More ergonomic syntax to avoid repeating coordinates?

packages/preview/fletcher/0.2.0/docs/examples/example-1.svg

Lines changed: 356 additions & 0 deletions
Loading

packages/preview/fletcher/0.2.0/docs/examples/example-2.svg

Lines changed: 356 additions & 0 deletions
Loading
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#import "/src/exports.typ": *
2+
3+
#for dark in (false, true) [
4+
5+
#let c = if dark { white } else { black }
6+
#set page(width: 22cm, height: 9cm, margin: 1cm)
7+
8+
#set text(fill: white) if dark
9+
10+
11+
#show: scale.with(200%, origin: top + left)
12+
13+
#let edge = edge.with(paint: c)
14+
15+
#stack(
16+
dir: ltr,
17+
spacing: 1cm,
18+
19+
fletcher.diagram(cell-size: 15mm, crossing-fill: none, {
20+
let (src, img, quo) = ((0, 1), (1, 1), (0, 0))
21+
node(src, $G$)
22+
node(img, $im f$)
23+
node(quo, $G slash ker(f)$)
24+
edge(src, img, $f$, "->")
25+
edge(quo, img, $tilde(f)$, "hook-->", label-side: right)
26+
edge(src, quo, $pi$, "->>")
27+
}),
28+
29+
fletcher.diagram(
30+
node-stroke: c,
31+
node-fill: rgb("aafa"),
32+
node-outset: 2pt,
33+
node((0,0), `typst`),
34+
node((1,0), "A"),
35+
node((2,0), "B", stroke: c + 2pt),
36+
node((2,1), "C"),
37+
38+
edge((0,0), (1,0), "->", bend: 15deg),
39+
edge((0,0), (1,0), "<-", bend: -15deg),
40+
edge((1,0), (2,1), "=>", bend: 20deg),
41+
edge((1,0), (2,0), "..>", bend: -0deg),
42+
),
43+
44+
)
45+
46+
]
Binary file not shown.

0 commit comments

Comments
 (0)