#import "@local/handout:0.1.0": *
#import "@preview/cetz:0.4.2"

#let markline(s, from, to, c: oblue) = {
  import cetz.draw: *
  let del = 0.4 // small line

  let arrow = (
    symbol: ")>",
    scale: s * 2.2,
    fill: c,
    stroke: c,
  )

  line(
    from + ".south",
    (v => cetz.vector.add(v, (0, -del * s)), from + ".south"),
    (v => cetz.vector.add(v, (0, (del + 0.4) * s)), to + ".north"),
    (v => cetz.vector.add(v, (0, 0.4 * s)), to + ".north"),
    stroke: c + s * 1mm,
  )
  mark(
    to + ".north",
    270deg,
    ..arrow,
  )
}


#let marklinetop(s, from, to, del: 0.8, c: oblue) = {
  import cetz.draw: *

  let arrow = (
    symbol: ")>",
    scale: s * 2.2,
    fill: c,
    stroke: c,
  )

  line(
    from + ".north",
    (v => cetz.vector.add(v, (0, del * s)), from + ".north"),
    (v => cetz.vector.add(v, (0, del * s)), to + ".north"),
    (v => cetz.vector.add(v, (0, 0.2 * s)), to + ".north"),
    stroke: c + s * 1mm,
  )
  mark(
    to + ".north",
    270deg,
    ..arrow,
  )
}



#let marklinebot(s, from, to, del: 0.8, c: oblue) = {
  import cetz.draw: *

  let arrow = (
    symbol: ")>",
    scale: s * 2.2,
    fill: c,
    stroke: c,
  )

  line(
    from + ".south",
    (v => cetz.vector.add(v, (0, -del * s)), from + ".south"),
    (v => cetz.vector.add(v, (0, -del * s)), to + ".south"),
    (v => cetz.vector.add(v, (0, -0.4 * s)), to + ".south"),
    stroke: c + s * 1mm,
  )
  mark(
    to + ".south",
    90deg,
    ..arrow,
  )
}



#let marklinebotswap(s, from, to, del: 0.8, c: oblue) = {
  import cetz.draw: *

  let arrow = (
    symbol: ")>",
    scale: s * 2.2,
    fill: c,
    stroke: c,
  )

  line(
    from + ".south",
    (v => cetz.vector.add(v, (0, -del * s)), from + ".south"),
    (v => cetz.vector.add(v, (0.5 * s, -del * s)), to + ".south"),
    (v => cetz.vector.add(v, (0.5 * s, -del * s)), to + ".south"),
    (v => cetz.vector.add(v, (0.5 * s, del * s)), to + ".north"),
    (v => cetz.vector.add(v, (0, del * s)), to + ".north"),
    (v => cetz.vector.add(v, (0, 0.2 * s)), to + ".north"),
    stroke: c + s * 1mm,
  )
  mark(
    to + ".north",
    270deg,
    ..arrow,
  )
}

#let marklinetopswap(s, from, to, del: 0.8, c: oblue) = {
  import cetz.draw: *

  let arrow = (
    symbol: ")>",
    scale: s * 2.2,
    fill: c,
    stroke: c,
  )

  line(
    from + ".north",
    (v => cetz.vector.add(v, (0, del * s)), from + ".north"),
    (v => cetz.vector.add(v, (0.5 * s, del * s)), to + ".north"),
    (v => cetz.vector.add(v, (0.5 * s, del * s)), to + ".north"),
    (v => cetz.vector.add(v, (0.5 * s, -del * s)), to + ".south"),
    (v => cetz.vector.add(v, (0, -del * s)), to + ".south"),
    (v => cetz.vector.add(v, (0, -0.2 * s)), to + ".south"),
    stroke: c + s * 1mm,
  )
  mark(
    to + ".south",
    90deg,
    ..arrow,
  )
}
