#Arrows for every occasion

16 messages · Page 1 of 1 (latest)

gray cloak
#

I've been obsessing over how to best implement customisable arrowheads (or "marks") for diagramming. I have a design which I think works well, and have a prototype in the master branch of https://github.com/Jollywatt/typst-fletcher. It's not published, so there's time for feedback and new ideas 🙂 It has three parts:

  1. How many "centres" does an arrowhead have? You might say one — the tip — but this design has four. Two to control where the mark is "pointing on", one when facing forward (tip-origin) and one when reversed (tail-origin); two more to control where the line stroke ends, one for forwards (tip-end) and one for backwards (tail-end). These four degrees of freedom allow for all sorts of mark alignment behaviours, although it's a bit complicated!

  2. What's the best way to represent marks as data in typst? You might suggest "functions which draw cetz objects at the given position and angle." I've settled on representing mark objects as dictionaries with a draw entry, and any other parameters you want, like size or angle or aspect. Taking advantage of the fact that dictionaries are ordered, entries can depend on ones before them, like so:

let example-mark-object = (
  size: 2,
  tip-end: mark => mark.size,
  draw: mark => cetz.draw.line((0, -mark.size), (0, +mark.size)),
)
  1. Lastly, how can marks be made user-customisable? Currently, all the marks are stored in a global state, which can be directly modified by the user. This means you have to understand and use contextual getter/setter functions, though. Perhaps there is a better user experience for this.

Points 2. and 3. appear in a little more detail in the fletcher manual: https://github.com/Jollywatt/typst-fletcher/blob/master/docs/manual.pdf?raw=true

A question for you

To anyone interested in diagramming with CeTZ or fletcher, what sorts of things to you want or need when it comes to arrows??

torn nimbus
#

Hi, this looks pretty sophisticated and well-thought out. I have a question: am I correct, that this uses CeTZ under the hood? Or would it also work "standalone"?

#

The reason I ask is that I'm the author of two diagramming packages, one unpublished, the other one quill but these are not built on top of CeTZ and use only the built-in drawing primitives.

#

Feedback: the 4-anchor system seems really useful. It is very frustrating when arrows don't point exactly where you need them be and it looks like your design accomodates for all needs required here! 👏

I wonder, maybe this will actually help in the future for arrows on bent lines. tikz has an option (the flex parameter I believe) to control how an arrow aligns with a curved line end to make it look more visually appealing

gray cloak
gray cloak
#

I'm impressed that quill doesn't use cetz! I thought it did. Nothing in particular is necesasrily specific to cetz except the actual drawing functions. Have a look at https://typst.app/project/r0TiG-66cPHBNrxJIRs3VH. Only mark-drawing.typ and mark-defaults.typ import cetz. Feel free to copy and build off that if you want to make one that doesn't use cetz

#

(The link above has the marks-related stuff I just copied from fletcher. It will diverge as fletcher changes.)

torn nimbus
edgy wraith
#

I'm sure you're familiar with https://tikz.dev/tikz-arrows @gray cloak

#

Looking at your list, I immediately noticed a lack of the Latex arrow, which has a slight curve to it

#

I think it looks nice

gray cloak
edgy wraith
#

I haven't looked much at Fletcher yet, but is the interface for arrows similar to the tikz library I linked to? (Presumably not quite as mature yet...)

gray cloak