implemented aligned notes
This commit is contained in:
		
							
								
								
									
										17
									
								
								src/note.typ
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								src/note.typ
									
									
									
									
									
								
							| @@ -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 | ||||
|   } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user