implemented aligned notes

This commit is contained in:
2024-06-21 17:26:50 +02:00
parent f08f30b9e2
commit 0cff9d6799
5 changed files with 94 additions and 12 deletions

View File

@ -15,6 +15,16 @@
)
#let _note(side, content, pos: none, color: COL-NOTE, shape: "default", aligned: false) = {
if side == "over" {
if pos == none {
panic("Pos cannot be none with side 'over'")
}
}
if aligned {
if side != "over" {
panic("Aligned notes can only be over a participant (got side '" + side + "')")
}
}
return ((
type: "note",
side: side,
@ -22,7 +32,8 @@
pos: pos,
color: color,
shape: shape,
aligned: aligned
aligned: aligned,
aligned-with: none
),)
}
@ -66,7 +77,7 @@
if note.side == "over" {
if type(note.pos) == array {
let xs = note.pos.map(par => x-pos.at(pars-i.at(par)))
return xs.sum() / xs.len()
return (calc.min(..xs) + calc.max(..xs)) / 2
}
}
return x-pos.at(pars-i.at(note.pos))
@ -162,7 +173,7 @@
anchor: "center"
)
if note.pos != none or note.side == "across" {
if note.aligned-with == none and (note.pos != none or note.side == "across") {
y -= h
}