added lifeline-style
This commit is contained in:
parent
ed84e06560
commit
4dd940f584
@ -13,8 +13,8 @@
|
||||
|
||||
#chronos.diagram({
|
||||
import chronos: *
|
||||
_seq("User", "A", comment: "DoWork", enable-dst: true)
|
||||
_seq("A", "A", comment: "Internal call", enable-dst: true)
|
||||
_seq("User", "A", comment: "DoWork", enable-dst: true, lifeline-style: (fill: rgb("#FFBBBB")))
|
||||
_seq("A", "A", comment: "Internal call", enable-dst: true, lifeline-style: (fill: rgb("#E9967A")))
|
||||
_seq("A", "B", comment: [#sym.quote.angle.l createRequest #sym.quote.angle.r], enable-dst: true)
|
||||
_seq("B", "A", comment: "RequestCreated", disable-src: true, disable-dst: true, dashed: true)
|
||||
_seq("A", "User", comment: "Done", disable-src: true)
|
||||
@ -24,8 +24,8 @@
|
||||
import chronos: *
|
||||
_seq("alice", "bob", comment: "hello", enable-dst: true)
|
||||
_seq("bob", "bob", comment: "self call", enable-dst: true)
|
||||
_seq("bill", "bob", comment: "hello from thread 2", enable-dst: true)
|
||||
_seq("bob", "george", comment: "create", enable-dst: true)
|
||||
_seq("bill", "bob", comment: "hello from thread 2", enable-dst: true, lifeline-style: (fill: rgb("#005500")))
|
||||
_seq("bob", "george", comment: "create", create-dst: true)
|
||||
_seq("bob", "bill", comment: "done in thread 2", disable-src: true, dashed: true)
|
||||
_seq("bob", "bob", comment: "rc", disable-src: true, dashed: true)
|
||||
_seq("bob", "george", comment: "delete", destroy-dst: true)
|
||||
|
@ -1,5 +1,5 @@
|
||||
#import "@preview/cetz:0.2.2": canvas, draw
|
||||
#import "utils.typ": get-participants-i
|
||||
#import "utils.typ": get-participants-i, get-style
|
||||
#import "group.typ"
|
||||
#import "sequence.typ"
|
||||
#import "separator.typ"
|
||||
@ -209,10 +209,12 @@
|
||||
|
||||
// Draw lifeline rectangles (reverse for bottom to top)
|
||||
for rect in rects.rev() {
|
||||
let (cx, y0, y1) = rect
|
||||
let (cx, y0, y1, style) = rect
|
||||
let style = get-style("lifeline", style)
|
||||
draw.rect(
|
||||
(cx - LIFELINE-W / 2, y0),
|
||||
(cx + LIFELINE-W / 2, y1)
|
||||
(cx + LIFELINE-W / 2, y1),
|
||||
..style
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -10,10 +10,12 @@
|
||||
color: black,
|
||||
flip: false,
|
||||
enable-dst: false,
|
||||
create-dst: false,
|
||||
disable-dst: false,
|
||||
destroy-dst: false,
|
||||
disable-src: false,
|
||||
destroy-src: false,
|
||||
lifeline-style: auto
|
||||
) = {
|
||||
return ((
|
||||
type: "seq",
|
||||
@ -25,10 +27,12 @@
|
||||
color: color,
|
||||
flip: flip,
|
||||
enable-dst: enable-dst,
|
||||
create-dst: create-dst,
|
||||
disable-dst: disable-dst,
|
||||
destroy-dst: destroy-dst,
|
||||
disable-src: disable-src,
|
||||
destroy-src: destroy-src,
|
||||
lifeline-style: lifeline-style,
|
||||
),)
|
||||
}
|
||||
|
||||
@ -45,7 +49,7 @@
|
||||
if elmt.disable-src {
|
||||
let src-line = lifelines.at(i1)
|
||||
src-line.level -= 1
|
||||
src-line.lines.push(("disable", y, auto))
|
||||
src-line.lines.push(("disable", y))
|
||||
lifelines.at(i1) = src-line
|
||||
}
|
||||
if elmt.destroy-src {
|
||||
@ -142,7 +146,12 @@
|
||||
}
|
||||
if elmt.enable-dst {
|
||||
let dst-line = lifelines.at(i2)
|
||||
dst-line.lines.push(("enable", y, auto))
|
||||
dst-line.lines.push(("enable", y, elmt.lifeline-style))
|
||||
lifelines.at(i2) = dst-line
|
||||
}
|
||||
if elmt.create-dst {
|
||||
let dst-line = lifelines.at(i2)
|
||||
dst-line.lines.push(("create", y))
|
||||
lifelines.at(i2) = dst-line
|
||||
}
|
||||
y -= Y-SPACE
|
||||
|
@ -24,4 +24,20 @@
|
||||
}
|
||||
}
|
||||
return (min-i, max-i)
|
||||
}
|
||||
|
||||
#let get-style(base-name, mods) = {
|
||||
let style = if base-name == "lifeline" {(
|
||||
fill: white,
|
||||
stroke: black + 1pt
|
||||
)}
|
||||
|
||||
if mods == auto {
|
||||
return style
|
||||
}
|
||||
if type(mods) == dictionary {
|
||||
return style + mods
|
||||
}
|
||||
|
||||
panic("Invalid type for parameter mods, expected auto or dictionary, got " + str(type(mods)))
|
||||
}
|
Loading…
Reference in New Issue
Block a user