Compare commits
2 Commits
b8d0c3468c
...
0e0be4e76a
Author | SHA1 | Date | |
---|---|---|---|
0e0be4e76a | |||
adc50124ad |
Binary file not shown.
@ -53,4 +53,22 @@ Alice <-- Bob: Another authentication Response
|
|||||||
_sep("Repetition")
|
_sep("Repetition")
|
||||||
_seq("Alice", "Bob", comment: "Another authentication Request")
|
_seq("Alice", "Bob", comment: "Another authentication Request")
|
||||||
_seq("Bob", "Alice", comment: "another authentication Response", dashed: true)
|
_seq("Bob", "Alice", comment: "another authentication Response", dashed: true)
|
||||||
|
})
|
||||||
|
|
||||||
|
#chronos.diagram({
|
||||||
|
import "/src/diagram.typ": *
|
||||||
|
_seq("Alice", "Bob", comment: "message 1")
|
||||||
|
_seq("Bob", "Alice", comment: "ok", dashed: true)
|
||||||
|
_gap()
|
||||||
|
_seq("Alice", "Bob", comment: "message 2")
|
||||||
|
_seq("Bob", "Alice", comment: "ok", dashed: true)
|
||||||
|
_gap(size: 45)
|
||||||
|
_seq("Alice", "Bob", comment: "message 3")
|
||||||
|
_seq("Bob", "Alice", comment: "ok", dashed: true)
|
||||||
|
})
|
||||||
|
|
||||||
|
#chronos.diagram({
|
||||||
|
import "/src/diagram.typ": *
|
||||||
|
_seq("Alice", "Alice", comment: "On the\nright")
|
||||||
|
_seq("Alice", "Alice", flip: true, comment: "On the\nleft")
|
||||||
})
|
})
|
@ -7,7 +7,8 @@
|
|||||||
comment: none,
|
comment: none,
|
||||||
dashed: false,
|
dashed: false,
|
||||||
tip: "default",
|
tip: "default",
|
||||||
color: black
|
color: black,
|
||||||
|
flip: false
|
||||||
) = {
|
) = {
|
||||||
return ((
|
return ((
|
||||||
type: "seq",
|
type: "seq",
|
||||||
@ -17,6 +18,7 @@
|
|||||||
dashed: dashed,
|
dashed: dashed,
|
||||||
tip: tip,
|
tip: tip,
|
||||||
color: color,
|
color: color,
|
||||||
|
flip: flip
|
||||||
),)
|
),)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,6 +57,13 @@
|
|||||||
),)
|
),)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#let _gap(size: 20) = {
|
||||||
|
return ((
|
||||||
|
type: "gap",
|
||||||
|
size: size
|
||||||
|
),)
|
||||||
|
}
|
||||||
|
|
||||||
#let diagram(elements) = {
|
#let diagram(elements) = {
|
||||||
let participants = ()
|
let participants = ()
|
||||||
let elmts = elements
|
let elmts = elements
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#let Y-SPACE = 10
|
#let Y-SPACE = 10
|
||||||
#let PAR-PAD = (5pt, 3pt)
|
#let PAR-PAD = (5pt, 3pt)
|
||||||
#let PAR-SPACE = 10
|
#let PAR-SPACE = 10
|
||||||
|
#let COMMENT-PAD = 8
|
||||||
|
|
||||||
|
|
||||||
#let get-columns-width(participants, elements) = {
|
#let get-columns-width(participants, elements) = {
|
||||||
@ -38,7 +39,7 @@
|
|||||||
let m = measure(cell.cell)
|
let m = measure(cell.cell)
|
||||||
widths.at(cell.i1) = calc.max(
|
widths.at(cell.i1) = calc.max(
|
||||||
widths.at(cell.i1),
|
widths.at(cell.i1),
|
||||||
m.width / 1pt
|
m.width / 1pt + COMMENT-PAD
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,22 +133,51 @@
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
if elmt.comment != none {
|
if elmt.p1 == elmt.p2 {
|
||||||
y -= measure(box(elmt.comment)).height / 1pt + 6
|
x2 = if elmt.flip {x1 - 20} else {x1 + 20}
|
||||||
draw.content(
|
|
||||||
(calc.min(x1, x2), y),
|
if elmt.comment != none {
|
||||||
elmt.comment,
|
y -= measure(box(elmt.comment)).height / 1pt + 6
|
||||||
anchor: "south-west",
|
draw.content(
|
||||||
padding: 3pt
|
(x1, y),
|
||||||
|
elmt.comment,
|
||||||
|
anchor: if elmt.flip {"south-east"} else {"south-west"},
|
||||||
|
padding: 3pt
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
draw.line(
|
||||||
|
(x1, y),
|
||||||
|
(x2, y),
|
||||||
|
(x2, y - 10),
|
||||||
|
(x1, y - 10),
|
||||||
|
..style
|
||||||
|
)
|
||||||
|
y -= 10
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if elmt.comment != none {
|
||||||
|
let x = calc.min(x1, x2)
|
||||||
|
if x2 < x1 {
|
||||||
|
x += COMMENT-PAD
|
||||||
|
}
|
||||||
|
y -= measure(box(elmt.comment)).height / 1pt + 6
|
||||||
|
draw.content(
|
||||||
|
(x, y),
|
||||||
|
elmt.comment,
|
||||||
|
anchor: "south-west",
|
||||||
|
padding: 3pt
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
draw.line(
|
||||||
|
(x1, y),
|
||||||
|
(x2, y),
|
||||||
|
..style
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
draw.line(
|
|
||||||
(x1, y),
|
|
||||||
(x2, y),
|
|
||||||
..style
|
|
||||||
)
|
|
||||||
y -= Y-SPACE
|
y -= Y-SPACE
|
||||||
|
|
||||||
} else if elmt.type == "grp" {
|
} else if elmt.type == "grp" {
|
||||||
let m = measure(
|
let m = measure(
|
||||||
box(
|
box(
|
||||||
@ -200,6 +230,8 @@
|
|||||||
)
|
)
|
||||||
y -= h / 2
|
y -= h / 2
|
||||||
y -= Y-SPACE
|
y -= Y-SPACE
|
||||||
|
} else if elmt.type == "gap" {
|
||||||
|
y -= elmt.size
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user