fixed and completed arrow tips
This commit is contained in:
		| @@ -16,10 +16,34 @@ | ||||
|     "/": (symbol: ">", fill: color, harpoon: true), | ||||
|     "//": (symbol: "straight", harpoon: true), | ||||
|     "x": none, | ||||
|     "o": (symbol: "o"), | ||||
|     "o": none, | ||||
|   ).at(sym) | ||||
| } | ||||
|  | ||||
| #let reverse-arrow-mark(mark) = { | ||||
|   if type(mark) == array { | ||||
|     return mark.map(m => reverse-arrow-mark(m)) | ||||
|   } | ||||
|   let mark2 = mark | ||||
|   if type(mark) == dictionary and mark.at("harpoon", default: false) { | ||||
|     let flipped = mark.at("flip", default: false) | ||||
|     mark2.insert("flip", not flipped) | ||||
|   } | ||||
|   return mark2 | ||||
| } | ||||
|  | ||||
| #let is-tip-of-type(type_, tip) = { | ||||
|   if type(tip) == str and tip == type_ { | ||||
|     return true | ||||
|   } | ||||
|   if type(tip) == array and tip.contains(type_) { | ||||
|     return true | ||||
|   } | ||||
|   return false | ||||
| } | ||||
| #let is-circle-tip = is-tip-of-type.with("o") | ||||
| #let is-cross-tip = is-tip-of-type.with("x") | ||||
|  | ||||
| #let _seq( | ||||
|   p1, | ||||
|   p2, | ||||
| @@ -175,6 +199,15 @@ | ||||
|     shapes += shps | ||||
|   } | ||||
|  | ||||
|   let flip-mark = end-info.i <= start-info.i | ||||
|   if elmt.flip { | ||||
|     flip-mark = not flip-mark | ||||
|   } | ||||
|   if flip-mark { | ||||
|     style.mark.end = reverse-arrow-mark(style.mark.end) | ||||
|   } | ||||
|  | ||||
|   let pts | ||||
|   if elmt.p1 == elmt.p2 { | ||||
|     if elmt.flip { | ||||
|       x1 = start-info.lx | ||||
| @@ -197,12 +230,11 @@ | ||||
|       ) | ||||
|     } | ||||
|  | ||||
|     shapes += draw.line( | ||||
|     pts = ( | ||||
|       (x1, start-info.y), | ||||
|       (x-mid, start-info.y), | ||||
|       (x-mid, end-info.y), | ||||
|       (x2, end-info.y), | ||||
|       ..style | ||||
|       (x2, end-info.y) | ||||
|     ) | ||||
|  | ||||
|   } else { | ||||
| @@ -219,12 +251,58 @@ | ||||
|       ) | ||||
|     } | ||||
|  | ||||
|     shapes += draw.line( | ||||
|     pts = ( | ||||
|       (x1, start-info.y), | ||||
|       (x2, end-info.y), | ||||
|       ..style | ||||
|       (x2, end-info.y) | ||||
|     ) | ||||
|   } | ||||
|  | ||||
|   // Start circle tip | ||||
|   if is-circle-tip(elmt.start-tip) { | ||||
|     shapes += draw.circle(pts.first(), radius: CIRCLE-TIP-RADIUS, stroke: elmt.color, fill: none, name: "_circle-start-tip") | ||||
|     pts.at(0) = "_circle-start-tip" | ||||
|    | ||||
|   // Start cross tip | ||||
|   } else if is-cross-tip(elmt.start-tip) { | ||||
|     let size = CROSS-TIP-SIZE | ||||
|     let cross-pt = (pts.first(), size * 2, pts.at(1)) | ||||
|     shapes += draw.line( | ||||
|       (rel: (-size, -size), to: cross-pt), | ||||
|       (rel: (size, size), to: cross-pt), | ||||
|       stroke: elmt.color + 1.5pt | ||||
|     ) | ||||
|     shapes += draw.line( | ||||
|       (rel: (-size, size), to: cross-pt), | ||||
|       (rel: (size, -size), to: cross-pt), | ||||
|       stroke: elmt.color + 1.5pt | ||||
|     ) | ||||
|     pts.at(0) = cross-pt | ||||
|   } | ||||
|  | ||||
|   // End circle tip | ||||
|   if is-circle-tip(elmt.end-tip) { | ||||
|     shapes += draw.circle(pts.last(), radius: 3, stroke: elmt.color, fill: none, name: "_circle-end-tip") | ||||
|     pts.at(pts.len() - 1) = "_circle-end-tip" | ||||
|    | ||||
|   // End cross tip | ||||
|   } else if is-cross-tip(elmt.end-tip) { | ||||
|     let size = CROSS-TIP-SIZE | ||||
|     let cross-pt = (pts.last(), size * 2, pts.at(pts.len() - 2)) | ||||
|     shapes += draw.line( | ||||
|       (rel: (-size, -size), to: cross-pt), | ||||
|       (rel: (size, size), to: cross-pt), | ||||
|       stroke: elmt.color + 1.5pt | ||||
|     ) | ||||
|     shapes += draw.line( | ||||
|       (rel: (-size, size), to: cross-pt), | ||||
|       (rel: (size, -size), to: cross-pt), | ||||
|       stroke: elmt.color + 1.5pt | ||||
|     ) | ||||
|     pts.at(pts.len() - 1) = cross-pt | ||||
|   } | ||||
|  | ||||
|   shapes += draw.line(..pts, ..style) | ||||
|  | ||||
|   if elmt.enable-dst { | ||||
|     let dst-line = lifelines.at(i2) | ||||
|     dst-line.lines.push(("enable", end-info.y, elmt.lifeline-style)) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user