Skip to content

Commit

Permalink
fletcher:0.4.0 (#363)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jollywatt authored Jan 30, 2024
1 parent 44d74e5 commit 26ed9b4
Show file tree
Hide file tree
Showing 16 changed files with 4,508 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/preview/fletcher/0.4.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.
82 changes: 82 additions & 0 deletions packages/preview/fletcher/0.4.0/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Fletcher

[![Manual](https://img.shields.io/badge/docs-manual.pdf-green)](https://github.com/Jollywatt/typst-fletcher/raw/master/docs/manual.pdf)
![Version](https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fgithub.com%2FJollywatt%2Farrow-diagrams%2Fraw%2Fmaster%2Ftypst.toml&query=package.version&label=version)
[![Repo](https://img.shields.io/badge/GitHub-repo-blue)](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 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 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.
43 changes: 43 additions & 0 deletions packages/preview/fletcher/0.4.0/docs/examples/example.typ
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 added packages/preview/fletcher/0.4.0/docs/manual.pdf
Binary file not shown.
Loading

0 comments on commit 26ed9b4

Please sign in to comment.