Skip to content

Commit

Permalink
fletcher:0.2.0 (#262)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jollywatt authored Nov 29, 2023
1 parent 8450b18 commit 5426e5f
Show file tree
Hide file tree
Showing 17 changed files with 3,068 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/preview/fletcher/0.2.0/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Joseph Wilson

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
48 changes: 48 additions & 0 deletions packages/preview/fletcher/0.2.0/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Fletcher

_(noun) a maker of arrows_

[![Manual](https://img.shields.io/badge/docs-manual.pdf-blue)](https://github.com/Jollywatt/typst-fletcher/raw/v0.2.0/docs/manual.pdf)
![Version](https://img.shields.io/badge/version-0.2.0-blue)

A [Typst]("https://typst.app/") package for drawing diagrams with arrows,
built on top of [CeTZ]("https://github.com/johannes-wolf/cetz").

<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/Jollywatt/typst-fletcher/raw/master/docs/examples/example-2.svg">
<img alt="logo" width="600" src="https://github.com/Jollywatt/typst-fletcher/raw/master/docs/examples/example-1.svg">
</picture>

```typ
#fletcher.diagram(cell-size: 15mm, {
let (src, img, quo) = ((0, 1), (1, 1), (0, 0))
node(src, $G$)
node(img, $im f$)
node(quo, $G slash ker(f)$)
edge(src, img, $f$, "->")
edge(quo, img, $tilde(f)$, "hook-->", label-side: right)
edge(src, quo, $pi$, "->>")
})
#fletcher.diagram(
node-stroke: black,
node-fill: blue.lighten(90%),
node((0,0), `typst`),
node((1,0), "A"),
node((2,0), "B", stroke: 2pt),
node((2,1), "C"),
edge((0,0), (1,0), "->", bend: 15deg),
edge((0,0), (1,0), "<-", bend: -15deg),
edge((1,0), (2,1), "=>", bend: 20deg),
edge((1,0), (2,0), "..>", bend: -0deg),
)
```

## Todo

- [x] Mathematical arrow styles
- [ ] Support CeTZ arrowheads
- [ ] Allow referring to node coordinates by their content
- [ ] Support loops connecting a node to itself
- [ ] More ergonomic syntax to avoid repeating coordinates?
356 changes: 356 additions & 0 deletions packages/preview/fletcher/0.2.0/docs/examples/example-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
356 changes: 356 additions & 0 deletions packages/preview/fletcher/0.2.0/docs/examples/example-2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions packages/preview/fletcher/0.2.0/docs/examples/example.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#import "/src/exports.typ": *

#for dark in (false, true) [

#let c = if dark { white } else { black }
#set page(width: 22cm, height: 9cm, margin: 1cm)

#set text(fill: white) if dark


#show: scale.with(200%, origin: top + left)

#let edge = edge.with(paint: c)

#stack(
dir: ltr,
spacing: 1cm,

fletcher.diagram(cell-size: 15mm, crossing-fill: none, {
let (src, img, quo) = ((0, 1), (1, 1), (0, 0))
node(src, $G$)
node(img, $im f$)
node(quo, $G slash ker(f)$)
edge(src, img, $f$, "->")
edge(quo, img, $tilde(f)$, "hook-->", label-side: right)
edge(src, quo, $pi$, "->>")
}),

fletcher.diagram(
node-stroke: c,
node-fill: rgb("aafa"),
node-outset: 2pt,
node((0,0), `typst`),
node((1,0), "A"),
node((2,0), "B", stroke: c + 2pt),
node((2,1), "C"),

edge((0,0), (1,0), "->", bend: 15deg),
edge((0,0), (1,0), "<-", bend: -15deg),
edge((1,0), (2,1), "=>", bend: 20deg),
edge((1,0), (2,0), "..>", bend: -0deg),
),

)

]
Binary file added packages/preview/fletcher/0.2.0/docs/manual.pdf
Binary file not shown.
Loading

0 comments on commit 5426e5f

Please sign in to comment.