jneug/typst-finite

Styling just the `Start` arrow

Quantumplation opened this issue · 4 comments

Is it possible to change the label and/or apply a color to just the Start transition?

For example:
image

In the first diagram, I've styled the Active state green, but it also applies to the incoming arrow.
And in the second diagram, I would like to style Start and the incoming arrow as green, without styling the state.

Right now it is only possible to change the direction of the arrow and the text.

I will consider expanding this for a future release.

Awesome, thanks! The library is really solid, I've enjoyed it so far!

How do I change the text? i wasn't able to find it in the documentation, but I might just be blind 😅

Have a look at the initial argument for #state on page 14.
You will habe to draw the automaton manually with #cetz.canvas.

I think you can also pass a dict to the styles key of #automaton with the name of the initial state like this:

styles: (
  "q0": (
    initial: "Start here"
  )
)

Seemed like an easy enough issue, so I added a styling option for initial states in 0.3.1.

You can now do this:

#automaton(
  (
    "Active": ("Done": "Cancel", "Active": ""),
    "Done": ()
  ),
  layout: layout.linear.with(spacing: 3),
  style: (
    "transition": (curve: .5),
    "Active-Active": (curve: 1),
    "Active": (
      stroke: green,
      initial: (
        stroke: black
      )
    )
  )
)

#automaton(
  (
    "Locked": ("Unlockable": "StartTimer"),
    "Unlockable": ("Unlocked": "CancelTimer"),
    "Unlocked": ()
  ),
  layout: layout.linear.with(spacing: 3),
  style: (
    "transition": (curve: .5),
    "Locked": (
      initial: (
        stroke: green
      )
    )
  )
)

You need to get the version from this repository for now, since it is not yet in the package repository.