-
Notifications
You must be signed in to change notification settings - Fork 469
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
4,508 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# Fletcher | ||
|
||
[](https://github.com/Jollywatt/typst-fletcher/raw/master/docs/manual.pdf) | ||
 | ||
[](https://github.com/Jollywatt/typst-fletcher) | ||
|
||
_**Fletcher** (noun) a maker of arrows_ | ||
|
||
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 | ||
#import "@preview/fletcher:0.4.0" as fletcher: node, edge | ||
#fletcher.diagram(cell-size: 15mm, $ | ||
G edge(f, ->) edge("d", pi, ->>) & im(f) \ | ||
G slash ker(f) edge("ur", tilde(f), "hook-->") | ||
$) | ||
#fletcher.diagram( | ||
node-fill: rgb("aafa"), | ||
node-outset: 2pt, | ||
axes: (ltr, btt), | ||
node((0,0), `typst`), | ||
node((1,0), "A"), | ||
node((2.5,0), "B", stroke: c + 2pt), | ||
node((2,1), "C", extrude: (+1, -1)), | ||
for i in range(3) { | ||
edge((0,0), (1,0), bend: (i - 1)*25deg) | ||
}, | ||
edge((1,0), (2,1), "..}>", corner: right), | ||
edge((1,0), (2.5,0), "-||-|>", bend: -0deg), | ||
), | ||
``` | ||
|
||
## Todo | ||
|
||
- [x] Mathematical arrow styles | ||
- [x] Also allow `&`-delimited equations for specifying nodes | ||
- [ ] Support CeTZ arrowheads | ||
- [ ] Support arbitrary node shapes drawn with CeTZ | ||
- [ ] Allow referring to node coordinates by their content? | ||
- [ ] Support loops connecting a node to itself | ||
- [x] More ergonomic syntax to avoid repeating coordinates? | ||
|
||
## Change log | ||
|
||
### 0.4.0 | ||
|
||
- Add ability to specify diagrams in math-mode, using `&` to separate nodes. | ||
- Allow implicit and relative edge coordinates, e.g., `edge("d")` becomes `edge(prev-node, (0, 1))`. | ||
- Add ability to place marks anywhere along an edge. Shorthands now accept an optional middle mark, for example `|->-|` and `hook-/->>`. | ||
- Add “hanging tail” correction to marks on curved edges. Marks now rotate a bit to fit more comfortably along tightly curving arcs. | ||
- Add more arrowheads for the sake of it: `}>`, `<{`, `/`, `\`, `x`, `X`, `*` (solid dot), `@` (solid circle). | ||
- Add `axes` option to `diagram()` to control the direction of each axis in the diagram's coordinate system. | ||
- Add `width`, `height` and `radius` options to `node()` for explicit control over size. | ||
- Add `corner-radius` option to `node()`. | ||
- Add `stroke` option to `edge()` replacing `thickness` and `paint` options. | ||
- Add `edge-stroke` option to `diagram()` replacing `edge-thickness`. | ||
|
||
### 0.3.0 | ||
|
||
- Make round-style arrow heads better approximate the default math font. | ||
- Add solid arrow heads with shorthand `<|-`, `-|>` and double-bar `||-`, `-||`. | ||
- Add an `extrude` option to `node()` which duplicates and extrudes the node's stroke, enabling double stroke effects. | ||
|
||
### 0.2.0 | ||
|
||
- Experimental support for customising arrowheads. | ||
- Add right-angled edges with `edge(..., corner: left/right)`. |
390 changes: 390 additions & 0 deletions
390
packages/preview/fletcher/0.4.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.
390 changes: 390 additions & 0 deletions
390
packages/preview/fletcher/0.4.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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#import "/src/exports.typ" as fletcher: node, edge | ||
|
||
#for dark-mode in (false, true) [ | ||
|
||
#let c = if dark-mode { white } else { black } | ||
#set page(width: 22cm, height: 9cm, margin: 1cm) | ||
|
||
#set text(fill: white) if dark-mode | ||
|
||
|
||
#show: scale.with(200%, origin: top + left) | ||
|
||
#let edge = edge.with(stroke: c) | ||
|
||
#stack( | ||
dir: ltr, | ||
spacing: 1cm, | ||
|
||
fletcher.diagram(cell-size: 15mm, crossing-fill: none, $ | ||
G edge(f, ->) edge("d", pi, ->>) & im(f) \ | ||
G slash ker(f) edge("ur", tilde(f), "hook-->") | ||
$), | ||
|
||
fletcher.diagram( | ||
node-stroke: c, | ||
node-fill: rgb("aafa"), | ||
node-outset: 2pt, | ||
axes: (ltr, btt), | ||
node((0,0), `typst`), | ||
node((1,0), "A"), | ||
node((2.5,0), "B", stroke: c + 2pt), | ||
node((2,1), "C", extrude: (+1, -1)), | ||
|
||
for i in range(3) { | ||
edge((0,0), (1,0), bend: (i - 1)*30deg) | ||
}, | ||
edge((1,0), (2,1), "..}>", corner: right), | ||
edge((1,0), (2.5,0), "-||-|>", bend: -0deg), | ||
), | ||
|
||
) | ||
|
||
] |
Binary file not shown.
Oops, something went wrong.