diff --git a/gallery/example1.pdf b/gallery/example1.pdf index 30c3a09..960c8ae 100644 Binary files a/gallery/example1.pdf and b/gallery/example1.pdf differ diff --git a/gallery/example1.typ b/gallery/example1.typ index 5ee06c8..4c9cee1 100644 --- a/gallery/example1.typ +++ b/gallery/example1.typ @@ -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) }) \ No newline at end of file diff --git a/src/diagram.typ b/src/diagram.typ index 75d7241..d152ac2 100644 --- a/src/diagram.typ +++ b/src/diagram.typ @@ -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, ),) } diff --git a/src/renderer.typ b/src/renderer.typ index 849d8ad..34192cc 100644 --- a/src/renderer.typ +++ b/src/renderer.typ @@ -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(