Compare commits
No commits in common. "81871e2aca77ba308e5b29c5a703857c6b117cb4" and "fd5b147e86170a2d9580693b02ea7b2b2aa91895" have entirely different histories.
81871e2aca
...
fd5b147e86
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,108 +0,0 @@
|
||||
#import "/src/lib.typ" as chronos
|
||||
|
||||
#set page(width: auto, height: auto)
|
||||
|
||||
#let TYPST = image("typst.png", width: 1.5cm, height: 1.5cm, fit: "contain")
|
||||
#let FERRIS = image("ferris.png", width: 1.5cm, height: 1.5cm, fit: "contain")
|
||||
#let ME = image("me.jpg", width: 1.5cm, height: 1.5cm, fit: "contain")
|
||||
|
||||
#chronos.diagram({
|
||||
import chronos: *
|
||||
_par("Foo", display-name: "Participant", shape: "participant")
|
||||
_par("Foo1", display-name: "Actor", shape: "actor")
|
||||
_par("Foo2", display-name: "Boundary", shape: "boundary")
|
||||
_par("Foo3", display-name: "Control", shape: "control")
|
||||
_par("Foo4", display-name: "Entity", shape: "entity")
|
||||
_par("Foo5", display-name: "Database", shape: "database")
|
||||
_par("Foo6", display-name: "Collections", shape: "collections")
|
||||
_par("Foo7", display-name: "Queue", shape: "queue")
|
||||
_par("Foo8", display-name: "Typst", shape: "custom", custom-image: TYPST)
|
||||
_par("Foo9", display-name: "Ferris", shape: "custom", custom-image: FERRIS)
|
||||
_par("Foo10", display-name: "Baryhobal", shape: "custom", custom-image: ME)
|
||||
|
||||
_seq("Foo", "Foo1", comment: "To actor")
|
||||
_seq("Foo", "Foo2", comment: "To boundary")
|
||||
_seq("Foo", "Foo3", comment: "To control")
|
||||
_seq("Foo", "Foo4", comment: "To entity")
|
||||
_seq("Foo", "Foo5", comment: "To database")
|
||||
_seq("Foo", "Foo6", comment: "To collections")
|
||||
_seq("Foo", "Foo7", comment: "To queue")
|
||||
_seq("Foo", "Foo8", comment: "To Typst")
|
||||
_seq("Foo", "Foo9", comment: "To ferris")
|
||||
_seq("Foo", "Foo10", comment: "To Baryhobal")
|
||||
})
|
||||
|
||||
#pagebreak()
|
||||
#chronos.diagram({
|
||||
import chronos: *
|
||||
_par("me", display-name: "Me", shape: "custom", custom-image: ME)
|
||||
_par("typst", display-name: "Typst", shape: "custom", custom-image: TYPST)
|
||||
_par("rust", display-name: "Rust", shape: "custom", custom-image: FERRIS)
|
||||
|
||||
_seq("me", "typst", comment: "opens document", enable-dst: true)
|
||||
_seq("me", "typst", comment: "types document")
|
||||
_seq("typst", "rust", comment: "compiles content", enable-dst: true)
|
||||
_seq("rust", "typst", comment: "renders document", disable-src: true)
|
||||
_seq("typst", "me", comment: "displays document")
|
||||
_evt("typst", "disable")
|
||||
})
|
||||
|
||||
#pagebreak()
|
||||
|
||||
#stack(dir: ltr, spacing: 1em,
|
||||
chronos.diagram({
|
||||
import chronos: *
|
||||
|
||||
_par("a", display-name: "Alice")
|
||||
_par("b", display-name: "Bob")
|
||||
|
||||
_seq("a", "b", end-tip: ">", comment: `->`)
|
||||
_seq("a", "b", end-tip: ">>", comment: `->>`)
|
||||
_seq("a", "b", end-tip: "\\", comment: `-\`)
|
||||
_seq("a", "b", end-tip: "\\\\", comment: `-\\`)
|
||||
_seq("a", "b", end-tip: "/", comment: `-/`)
|
||||
_seq("a", "b", end-tip: "//", comment: `-//`)
|
||||
_seq("a", "b", end-tip: "x", comment: `->x`)
|
||||
_seq("a", "b", start-tip: "x", comment: `x->`)
|
||||
_seq("a", "b", start-tip: "o", comment: `o->`)
|
||||
_seq("a", "b", end-tip: "o", comment: `->o`)
|
||||
_seq("a", "b", start-tip: "o", end-tip: "o", comment: `o->o`)
|
||||
_seq("a", "b", start-tip: ">", end-tip: ">", comment: `<->`)
|
||||
_seq("a", "b", start-tip: ("o", ">"), end-tip: ("o", ">"), comment: `o<->o`)
|
||||
_seq("a", "b", start-tip: ("x", ">"), end-tip: ("x", ">"), comment: `x<->x`)
|
||||
_seq("a", "b", end-tip: ("o", ">>"), comment: `->>o`)
|
||||
_seq("a", "b", end-tip: ("o", "\\"), comment: `-\o`)
|
||||
_seq("a", "b", end-tip: ("o", "\\\\"), comment: `-\\o`)
|
||||
_seq("a", "b", end-tip: ("o", "/"), comment: `-/o`)
|
||||
_seq("a", "b", end-tip: ("o", "//"), comment: `-//o`)
|
||||
_seq("a", "b", start-tip: "x", end-tip: ("o", ">"), comment: `x->o`)
|
||||
}),
|
||||
|
||||
chronos.diagram({
|
||||
import chronos: *
|
||||
|
||||
_par("a", display-name: "Alice")
|
||||
_par("b", display-name: "Bob")
|
||||
|
||||
_seq("a", "a", end-tip: ">", comment: `->`)
|
||||
_seq("a", "a", end-tip: ">>", comment: `->>`)
|
||||
_seq("a", "a", end-tip: "\\", comment: `-\`)
|
||||
_seq("a", "a", end-tip: "\\\\", comment: `-\\`)
|
||||
_seq("a", "a", end-tip: "/", comment: `-/`)
|
||||
_seq("a", "a", end-tip: "//", comment: `-//`)
|
||||
_seq("a", "a", end-tip: "x", comment: `->x`)
|
||||
_seq("a", "a", start-tip: "x", comment: `x->`)
|
||||
_seq("a", "a", start-tip: "o", comment: `o->`)
|
||||
_seq("a", "a", end-tip: "o", comment: `->o`)
|
||||
_seq("a", "a", start-tip: "o", end-tip: "o", comment: `o->o`)
|
||||
_seq("a", "a", start-tip: ">", end-tip: ">", comment: `<->`)
|
||||
_seq("a", "a", start-tip: ("o", ">"), end-tip: ("o", ">"), comment: `o<->o`)
|
||||
_seq("a", "a", start-tip: ("x", ">"), end-tip: ("x", ">"), comment: `x<->x`)
|
||||
_seq("a", "a", end-tip: ("o", ">>"), comment: `->>o`)
|
||||
_seq("a", "a", end-tip: ("o", "\\"), comment: `-\o`)
|
||||
_seq("a", "a", end-tip: ("o", "\\\\"), comment: `-\\o`)
|
||||
_seq("a", "a", end-tip: ("o", "/"), comment: `-/o`)
|
||||
_seq("a", "a", end-tip: ("o", "//"), comment: `-//o`)
|
||||
_seq("a", "a", start-tip: "x", end-tip: ("o", ">"), comment: `x->o`)
|
||||
})
|
||||
)
|
Binary file not shown.
Before Width: | Height: | Size: 25 KiB |
BIN
gallery/me.jpg
BIN
gallery/me.jpg
Binary file not shown.
Before Width: | Height: | Size: 530 KiB |
Binary file not shown.
Before Width: | Height: | Size: 42 KiB |
@ -9,15 +9,6 @@
|
||||
),)
|
||||
}
|
||||
|
||||
#let _evt(participant, event) = {
|
||||
return ((
|
||||
type: "evt",
|
||||
participant: participant,
|
||||
event: event,
|
||||
lifeline-style: auto
|
||||
),)
|
||||
}
|
||||
|
||||
#let diagram(elements) = {
|
||||
if elements == none {
|
||||
return
|
||||
|
@ -1,4 +1,4 @@
|
||||
#import "diagram.typ": diagram, from-plantuml, _gap, _evt
|
||||
#import "diagram.typ": diagram, from-plantuml, _gap
|
||||
|
||||
#import "sequence.typ": _seq
|
||||
#import "group.typ": _grp
|
||||
|
@ -49,18 +49,6 @@
|
||||
p.max-lifelines = calc.max(p.max-lifelines, p.lifeline-lvl)
|
||||
participants.at(i2) = p
|
||||
}
|
||||
} else if elmt.type == "evt" {
|
||||
let par-name = elmt.participant
|
||||
let i = pars-i.at(par-name)
|
||||
let par = participants.at(i)
|
||||
if elmt.event == "disable" or elmt.event == "destroy" {
|
||||
par.lifeline-lvl -= 1
|
||||
|
||||
} else if elmt.event == "enable" {
|
||||
par.lifeline-lvl += 1
|
||||
par.max-lifelines = calc.max(par.max-lifelines, par.lifeline-lvl)
|
||||
}
|
||||
participants.at(i) = par
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,21 +74,6 @@
|
||||
)
|
||||
}
|
||||
|
||||
// Compute minimum width for self sequences
|
||||
for cell in cells.filter(c => c.i1 == c.i2) {
|
||||
let m = measure(cell.cell)
|
||||
let i = cell.i1
|
||||
if cell.elmt.flip {
|
||||
i -= 1
|
||||
}
|
||||
if 0 <= i and i < widths.len() {
|
||||
widths.at(i) = calc.max(
|
||||
widths.at(i),
|
||||
m.width / 1pt + COMMENT-PAD
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// Compute remaining widths for longer sequences (spanning multiple columns)
|
||||
let multicol-cells = cells.filter(c => c.i2 - c.i1 > 1)
|
||||
multicol-cells = multicol-cells.sorted(key: c => {
|
||||
@ -151,7 +124,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
let y = 0
|
||||
let y = -Y-SPACE
|
||||
let groups = ()
|
||||
let lifelines = participants.map(_ => (
|
||||
level: 0,
|
||||
@ -168,7 +141,6 @@
|
||||
|
||||
// Groups (start) -> reserve space for labels + store position
|
||||
} else if elmt.type == "grp" {
|
||||
y -= Y-SPACE
|
||||
let m = measure(
|
||||
box(
|
||||
elmt.name,
|
||||
@ -181,16 +153,17 @@
|
||||
g
|
||||
})
|
||||
groups.push((y, elmt, 0, 0))
|
||||
y -= m.height / 1pt
|
||||
y -= m.height / 1pt + Y-SPACE
|
||||
|
||||
// Groups (end) -> actual drawing
|
||||
} else if elmt.type == "grp-end" {
|
||||
y -= Y-SPACE
|
||||
let (start-y, group, start-lvl, end-lvl) = groups.pop()
|
||||
let x0 = x-pos.at(group.min-i) - start-lvl * 10 - 20
|
||||
let x1 = x-pos.at(group.max-i) + end-lvl * 10 + 20
|
||||
shapes += draw-group(x0, x1, start-y, y, group)
|
||||
|
||||
y -= Y-SPACE
|
||||
|
||||
// Separator
|
||||
} else if elmt.type == "sep" {
|
||||
let shps
|
||||
@ -200,34 +173,9 @@
|
||||
// Gap
|
||||
} else if elmt.type == "gap" {
|
||||
y -= elmt.size
|
||||
|
||||
// Event
|
||||
} else if elmt.type == "evt" {
|
||||
let par-name = elmt.participant
|
||||
let i = pars-i.at(par-name)
|
||||
let par = participants.at(i)
|
||||
let line = lifelines.at(i)
|
||||
if elmt.event == "disable" {
|
||||
line.level -= 1
|
||||
line.lines.push(("disable", y))
|
||||
|
||||
} else if elmt.event == "destroy" {
|
||||
line.lines.push(("destroy", y))
|
||||
|
||||
} else if elmt.event == "enable" {
|
||||
line.level += 1
|
||||
line.lines.push(("enable", y, elmt.lifeline-style))
|
||||
|
||||
} else if elmt.event == "create" {
|
||||
shapes += participant.render(x-pos, par, y: y)
|
||||
line.lines.push(("create", y))
|
||||
}
|
||||
lifelines.at(i) = line
|
||||
}
|
||||
}
|
||||
|
||||
y -= Y-SPACE
|
||||
|
||||
// Draw vertical lines + lifelines + end participants
|
||||
shapes += draw.on-layer(-1, {
|
||||
if DEBUG-INVISIBLE {
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
#let render(x-pos, elmt, y) = {
|
||||
let shapes = ()
|
||||
y -= Y-SPACE
|
||||
|
||||
let x0 = x-pos.first() - 20
|
||||
let x1 = x-pos.last() + 20
|
||||
@ -49,6 +48,7 @@
|
||||
fill: COL-SEP-NAME
|
||||
)
|
||||
y -= h / 2
|
||||
y -= Y-SPACE
|
||||
|
||||
let r = (y, shapes)
|
||||
return r
|
||||
|
@ -2,30 +2,12 @@
|
||||
#import "consts.typ": *
|
||||
#import "participant.typ"
|
||||
|
||||
#let get-arrow-marks(sym, color) = {
|
||||
if type(sym) == array {
|
||||
return sym.map(s => get-arrow-marks(s, color))
|
||||
}
|
||||
(
|
||||
"": none,
|
||||
">": (symbol: ">", fill: color),
|
||||
">>": (symbol: "straight"),
|
||||
"\\": (symbol: ">", fill: color, harpoon: true, flip: true),
|
||||
"\\\\": (symbol: "straight", harpoon: true, flip: true),
|
||||
"/": (symbol: ">", fill: color, harpoon: true),
|
||||
"//": (symbol: "straight", harpoon: true),
|
||||
"x": none,
|
||||
"o": (symbol: "o"),
|
||||
).at(sym)
|
||||
}
|
||||
|
||||
#let _seq(
|
||||
p1,
|
||||
p2,
|
||||
comment: none,
|
||||
dashed: false,
|
||||
start-tip: "",
|
||||
end-tip: ">",
|
||||
tip: "default",
|
||||
color: black,
|
||||
flip: false,
|
||||
enable-dst: false,
|
||||
@ -42,8 +24,7 @@
|
||||
p2: p2,
|
||||
comment: comment,
|
||||
dashed: dashed,
|
||||
start-tip: start-tip,
|
||||
end-tip: end-tip,
|
||||
tip: tip,
|
||||
color: color,
|
||||
flip: flip,
|
||||
enable-dst: enable-dst,
|
||||
@ -59,8 +40,6 @@
|
||||
#let render(pars-i, x-pos, participants, elmt, y, lifelines) = {
|
||||
let shapes = ()
|
||||
|
||||
y -= Y-SPACE
|
||||
|
||||
// Reserve space for comment
|
||||
if elmt.comment != none {
|
||||
y -= measure(box(elmt.comment)).height / 1pt + 6
|
||||
@ -138,10 +117,7 @@
|
||||
}
|
||||
|
||||
let style = (
|
||||
mark: (
|
||||
start: get-arrow-marks(elmt.start-tip, elmt.color),
|
||||
end: get-arrow-marks(elmt.end-tip, elmt.color)
|
||||
),
|
||||
mark: (end: ">", fill: elmt.color),
|
||||
stroke: (
|
||||
dash: if elmt.dashed {"dashed"} else {"solid"},
|
||||
paint: elmt.color
|
||||
@ -209,6 +185,7 @@
|
||||
dst-line.lines.push(("create", y))
|
||||
lifelines.at(i2) = dst-line
|
||||
}
|
||||
y -= Y-SPACE
|
||||
|
||||
let r = (y, lifelines, shapes)
|
||||
return r
|
||||
|
Loading…
Reference in New Issue
Block a user