added some styling options

This commit is contained in:
Louis Heredero 2024-06-18 13:51:01 +02:00
parent 14cbda2ffb
commit 974eb92159
Signed by: HEL
GPG Key ID: 8D83DE470F8544E7
4 changed files with 29 additions and 6 deletions

Binary file not shown.

View File

@ -12,8 +12,14 @@ Alice <-- Bob: Another authentication Response
#chronos.diagram({
import "/src/diagram.typ": *
_seq("Alice", "Bob", comment: "Authentication Request")
_seq("Bob", "Alice", comment: "Authentication Response", style: "dashed")
_seq("Bob", "Alice", comment: "Authentication Response", dashed: true)
_seq("Alice", "Bob", comment: "Another authentication Request")
_seq("Bob", "Alice", comment: "Another authentication Response", style: "dashed")
_seq("Bob", "Alice", comment: "Another authentication Response", dashed: true)
})
#chronos.diagram({
import "/src/diagram.typ": *
_seq("Bob", "Alice", comment: "bonjour", color: red)
_seq("Alice", "Bob", comment: "ok", color: blue)
})

View File

@ -1,12 +1,21 @@
#import "renderer.typ": render
#let _seq(p1, p2, comment: none, style: auto) = {
#let _seq(
p1,
p2,
comment: none,
dashed: false,
tip: "default",
color: black
) = {
return ((
type: "seq",
p1: p1,
p2: p2,
comment: comment,
style: style
dashed: dashed,
tip: tip,
color: color,
),)
}

View File

@ -1,7 +1,7 @@
#import "@preview/cetz:0.2.2": canvas, draw
#let X-SPACE = 2
#let Y-SPACE = 30
#let Y-SPACE = 20
#let get-participants-i(participants) = {
let pars-i = (:)
@ -69,10 +69,18 @@
if elmt.type == "seq" {
let x1 = x-pos.at(pars-i.at(elmt.p1))
let x2 = x-pos.at(pars-i.at(elmt.p2))
let style = (
mark: (end: "straight"),
stroke: (
dash: if elmt.dashed {"dashed"} else {"solid"},
paint: elmt.color
)
)
draw.line(
(x1, y),
(x2, y),
mark: (end: "straight")
..style
)
if elmt.comment != none {
draw.content(