From ebd4d8f1ca764ab279c4d66ed2ecd8f57e790c9f Mon Sep 17 00:00:00 2001 From: LordBaryhobal Date: Tue, 30 Jul 2024 12:38:23 +0200 Subject: [PATCH] added synched sequences --- gallery/example2.pdf | Bin 37710 -> 38162 bytes gallery/example2.typ | 35 +++++++++++++++++++++++++++++++++++ src/lib.typ | 3 ++- src/renderer.typ | 8 ++++++++ src/sync.typ | 27 +++++++++++++++++++++++++++ 5 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 src/sync.typ diff --git a/gallery/example2.pdf b/gallery/example2.pdf index bb798e87d8135b0c613a840858218eff5d52d214..20e2e3327921ba031b0965af256157c5c3972b1d 100644 GIT binary patch delta 2349 zcmZ`(X*kr49&Ivq6A8(_4919NjKK(vHTzPE5HVvJjBP|Af7{5Cb&x@!vNX1Y(qs!| zXJp?(S>G00MI^W0`{6#%z3)Ar&hMP_JmIo-L3U(~41uG9Nk_X$feRs&X{XMpX&(ZUz)!zEq zFlRzB3GdL^8LY}`iaM)6sN3)Nbid4D0FD@x_qkIzVP^uJx_a!8Ys3`x7A#zxa~d2! zs15(Iw(WOVWV^!jYGw~$x!1DCZx$!h*JX*%~Gqwqgc%4 zHVGQ?;%Z=@;Ttcrj+{xzN|qC}K3dhb;M_qHwm_FFMEk zI^zNu$sjlARr2Ov0tW&wC9V18khL_~!X`pFxhFZ>W(@t2k*{>(<}zL8sf@j3mhX(A z*%uXQz+sgwQC=y_(BL&f(t5vjaXK&k^Jn$RmkSOViy(H$qqoWU`V;8c@eG9R%c8#A z55Gj5j`^L(O5r+4`s}6*6Ku%p7Mn&Grit%bJF zEg^Y+xTMfTK?A3h`w`faesKj#*kXHm1EiY<0O@vPzQBw9%QvobdU4^+;L1Ru`k4C~ zm*)Mb!TUOJfCV(xR)W(}@P0sgmZ_w>?XCvZfSDyN2Zf>xZ0y_o)Ohsaz8ZOLt`Byb zHXvMagCpQNHDW!FZ|3k3lB_Q2J0xmnxu7fClRUKOEgO=Xt{8N>S+ZO(S=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B@aE zGfV-ei9({zApdWdmBmVc4`&AA6rdO-6kq{hGyzpjBqoU?{+|jq{>2G>D}tlt6*n`A znW7`w3Uk5O+6sTgC22oi{y(fTt%M8^1dTxhWh03\]\ from actor1 *to end*]) _seq("Alice", "?", comment: [->?\ *short* from actor1]) _seq("Alice", "Bob", comment: [->\ from actor1 to actor2]) +}) + +#chronos.diagram({ + import chronos: * + _par("alice", display-name: "Alice") + _par("bob", display-name: "Bob") + _par("craig", display-name: "Craig") + + _seq("bob", "alice") + _seq("bob", "craig") + _gap() + + _sync({ + _seq("bob", "alice") + _seq("bob", "craig") + }) + _gap() + + _seq("alice", "bob") + _seq("craig", "bob") + _gap() + + _sync({ + _seq("alice", "bob") + _seq("craig", "bob") + }) + _gap() + + _sync({ + _seq("alice", "bob", enable-dst: true) + _seq("craig", "bob") + }) + _gap() + + _evt("bob", "disable") }) \ No newline at end of file diff --git a/src/lib.typ b/src/lib.typ index f44c8e9..ec5d651 100644 --- a/src/lib.typ +++ b/src/lib.typ @@ -4,4 +4,5 @@ #import "group.typ": _grp #import "participant.typ": _par #import "separator.typ": _sep -#import "note.typ": _note \ No newline at end of file +#import "note.typ": _note +#import "sync.typ": _sync \ No newline at end of file diff --git a/src/renderer.typ b/src/renderer.typ index a4ed4bd..8953a40 100644 --- a/src/renderer.typ +++ b/src/renderer.typ @@ -5,6 +5,7 @@ #import participant: PAR-SPECIALS #import "sequence.typ" #import "separator.typ" +#import "sync.typ" #import "consts.typ": * #import "note.typ" as note: get-note-box @@ -203,6 +204,7 @@ let draw-sep = separator.render.with(x-pos) let draw-par = participant.render.with(x-pos) let draw-note = note.render.with(pars-i, x-pos) + let draw-sync = sync.render.with(pars-i, x-pos, participants) // Draw participants (start) for p in participants { @@ -295,6 +297,12 @@ (y, shps) = draw-note(elmt, y, lifelines) shapes += shps } + + // Synched sequences + } else if elmt.type == "sync" { + let shps + (y, lifelines, shps) = draw-sync(elmt, y, lifelines) + shapes += shps } } diff --git a/src/sync.typ b/src/sync.typ new file mode 100644 index 0000000..41f0891 --- /dev/null +++ b/src/sync.typ @@ -0,0 +1,27 @@ +#import "sequence.typ" + +#let _sync(elmts) = { + return (( + type: "sync", + elmts: elmts + ),) +} + +#let render(pars-i, x-pos, participants, elmt, y, lifelines) = { + let draw-seq = sequence.render.with(pars-i, x-pos, participants) + + let shapes = () + + let end-y = y + + for e in elmt.elmts { + let yi + let shps + (yi, lifelines, shps) = draw-seq(e, y, lifelines) + shapes += shps + end-y = calc.min(end-y, yi) + } + + let r = (end-y, lifelines, shapes) + return r +} \ No newline at end of file