{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "illustration-11",
  "title": "Region wheel",
  "description": "A drum of server regions to flick, drag or step with the arrow keys, where the globe turns to the route from the visitor as each region passes and the latency estimate rolls.",
  "dependencies": [],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/demonstration.json",
    "https://ui.ndekocode.dev/r/live-region.json",
    "https://ui.ndekocode.dev/r/motion-globe.json",
    "https://ui.ndekocode.dev/r/motion-number.json",
    "https://ui.ndekocode.dev/r/motion-word-roll.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/use-autoplay.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json",
    "https://ui.ndekocode.dev/r/utils.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/components/illustration/illustration-11.tsx",
      "content": "'use client';\n\nimport { useEffect, useId, useMemo, useRef, useState } from 'react';\n\nimport {\n  Globe,\n  type GlobeArc,\n  type GlobeLocation,\n  type GlobeMarker,\n} from '@/components/core/globe';\nimport { MotionNumber } from '@/components/core/motion-number';\nimport { WordRoll } from '@/components/core/word-roll';\nimport {\n  useAutoplay,\n  type AutoplayStep,\n} from '@/registry/ndeko/hooks/use-autoplay';\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { spokenUnless } from '@/registry/ndeko/lib/demonstration';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { LiveRegion } from '@/registry/ndeko/ui/live-region';\n\nimport { degreesOf, radiansOf, rounded } from './_parts/geometry';\n\nexport type WheelPlace = {\n  id: string;\n  name: string;\n  location: GlobeLocation;\n};\n\ntype Pose = {\n  transform: string;\n  opacity: number;\n};\n\n/** A point of the sphere of radius one: towards longitude zero, towards longitude 90 east, towards the north pole. */\ntype Direction = [x: number, y: number, z: number];\n\ntype Wheel = {\n  /** True for an index the wheel itself reported while it turned: the parent only hands it back. */\n  isEcho: (index: number) => boolean;\n  glideTo: (index: number, isInstant: boolean) => void;\n  step: (by: number, isInstant: boolean) => void;\n  press: (event: PointerEvent) => void;\n  drag: (event: PointerEvent) => void;\n  release: (event: PointerEvent, isInstant: boolean) => void;\n  cancel: (isInstant: boolean) => void;\n  dispose: () => void;\n};\n\nconst ITEM_PX = 36;\n\n/** The wheel is a drum: each item sits this many degrees further round it than the one before. */\nconst STEP_DEG = 22;\n\nconst STEP_RAD = radiansOf(STEP_DEG);\n\nconst DRUM_RADIUS_PX = ITEM_PX / Math.sin(STEP_RAD);\n\nconst QUARTER_TURN_DEG = 90;\n\nconst SMALLEST_SCALE = 0.72;\n\n/** A press becomes a drag once the pointer has moved this far: under it, it is a tap on a region. */\nconst DRAG_AFTER_PX = 4;\n\n/** Past its first or last region the wheel gives, a third as far as it is pulled. */\nconst GIVE_PAST_END = 0.35;\n\n/** How far a flick carries the wheel: where it would land after this long at the speed it was let go. */\nconst MOMENTUM_MS = 260;\n\nconst HELD_STILL_MS = 80;\n\nconst GLIDE_EASE_MS = 130;\n\n/** A frame that comes late, after a hidden tab, turns the wheel no further than this long would. */\nconst MAX_STEP_MS = 50;\n\nconst SETTLED_WITHIN = 0.002;\n\nconst MAX_ECHOES = 16;\n\nconst EARTH_RADIUS_KM = 6371;\n\n/** A round trip over fibre covers about a hundred kilometres each way per millisecond, after a fixed cost at both ends. */\nconst FIXED_LATENCY_MS = 8;\n\nconst KM_PER_ROUND_TRIP_MS = 50;\n\n/**\n * How far to the side of the route the globe looks from. Seen from straight above the middle of the\n * route, its arc lies edge on and reads as a straight line.\n */\nconst VIEW_ASIDE_DEG = 20;\n\nfunction poseOf(offset: number): Pose {\n  const angle = offset * STEP_DEG;\n  const isBehind = Math.abs(angle) >= QUARTER_TURN_DEG;\n  if (isBehind) {\n    return { transform: 'translateY(0px) scale(0)', opacity: 0 };\n  }\n  const radians = radiansOf(angle);\n  const facing = Math.cos(radians);\n  const drop = Math.sin(radians) * DRUM_RADIUS_PX;\n  const grown = (1 - SMALLEST_SCALE) * facing;\n  const down = rounded(drop);\n  const scale = rounded(SMALLEST_SCALE + grown);\n  return {\n    transform: `translateY(${down}px) scale(${scale})`,\n    opacity: rounded(facing * facing),\n  };\n}\n\nfunction boundedIndexOf(index: number, lastIndex: number) {\n  const atLeastFirst = Math.max(0, index);\n  return Math.min(lastIndex, atLeastFirst);\n}\n\nfunction withGiveOf(raw: number, lastIndex: number) {\n  if (raw < 0) {\n    return raw * GIVE_PAST_END;\n  }\n  if (raw > lastIndex) {\n    const past = raw - lastIndex;\n    return lastIndex + past * GIVE_PAST_END;\n  }\n  return raw;\n}\n\nfunction shareOf(elapsedMs: number, easeMs: number) {\n  const decay = Math.exp(-elapsedMs / easeMs);\n  return 1 - decay;\n}\n\n/**\n * The wheel moves outside React: a drag and a glide write the pose of every item to its element, and\n * frames are asked for only while it turns. React hears about it when another region reaches the centre.\n */\nfunction createWheel(\n  host: HTMLElement,\n  startIndex: number,\n  onNearest: (index: number) => void\n): Wheel {\n  const found = host.querySelectorAll<HTMLElement>('[role=\"option\"]');\n  const items = Array.from(found);\n  const lastIndex = Math.max(items.length - 1, 0);\n  const echoes: number[] = [];\n  let position = startIndex;\n  let target = startIndex;\n  let reported = startIndex;\n  let velocity = 0;\n  let isPressed = false;\n  let isDragging = false;\n  let pressY = 0;\n  let grabY = 0;\n  let grabPosition = 0;\n  let lastMoveAt = 0;\n  let frame = 0;\n  let lastTick = 0;\n\n  function paint() {\n    items.forEach((item, index) => {\n      const pose = poseOf(index - position);\n      item.style.transform = pose.transform;\n      item.style.opacity = `${pose.opacity}`;\n    });\n  }\n\n  function report() {\n    const closest = Math.round(position);\n    const nearest = boundedIndexOf(closest, lastIndex);\n    if (nearest === reported) {\n      return;\n    }\n    reported = nearest;\n    echoes.push(nearest);\n    if (echoes.length > MAX_ECHOES) {\n      echoes.shift();\n    }\n    onNearest(nearest);\n  }\n\n  function show() {\n    paint();\n    report();\n  }\n\n  function tick(now: number) {\n    const sinceLast = now - lastTick;\n    const elapsed = Math.min(sinceLast, MAX_STEP_MS);\n    const gap = target - position;\n    const share = shareOf(elapsed, GLIDE_EASE_MS);\n    lastTick = now;\n    position += gap * share;\n    const isSettled = Math.abs(target - position) < SETTLED_WITHIN;\n    if (isSettled) {\n      position = target;\n      frame = 0;\n      show();\n      return;\n    }\n    show();\n    frame = requestAnimationFrame(tick);\n  }\n\n  function wake() {\n    if (frame !== 0) {\n      return;\n    }\n    lastTick = performance.now();\n    frame = requestAnimationFrame(tick);\n  }\n\n  function sleep() {\n    cancelAnimationFrame(frame);\n    frame = 0;\n  }\n\n  function aimAt(index: number, isInstant: boolean) {\n    target = boundedIndexOf(index, lastIndex);\n    if (isInstant) {\n      sleep();\n      position = target;\n      show();\n      return;\n    }\n    wake();\n  }\n\n  /** The region under a tap. Items sit closer together towards the rims of the drum, so the height is read back as an angle. */\n  function tappedIndexOf(event: PointerEvent) {\n    const box = host.getBoundingClientRect();\n    const middle = box.top + box.height / 2;\n    const fromMiddle = (event.clientY - middle) / DRUM_RADIUS_PX;\n    const atLeast = Math.max(-1, fromMiddle);\n    const reach = Math.min(1, atLeast);\n    const radians = Math.asin(reach);\n    const itemsAway = degreesOf(radians) / STEP_DEG;\n    return Math.round(position + itemsAway);\n  }\n\n  return {\n    isEcho(index) {\n      const at = echoes.indexOf(index);\n      if (at === -1) {\n        return false;\n      }\n      echoes.splice(0, at + 1);\n      return true;\n    },\n    glideTo(index, isInstant) {\n      const isThere = position === index;\n      const isHeading = target === index;\n      if (isThere && isHeading) {\n        return;\n      }\n      echoes.length = 0;\n      aimAt(index, isInstant);\n    },\n    step(by, isInstant) {\n      aimAt(target + by, isInstant);\n    },\n    press(event) {\n      const isMainButton = event.button === 0;\n      if (!isMainButton) {\n        return;\n      }\n      isPressed = true;\n      isDragging = false;\n      pressY = event.clientY;\n      host.setPointerCapture(event.pointerId);\n    },\n    drag(event) {\n      if (!isPressed) {\n        return;\n      }\n      if (!isDragging) {\n        const travelled = Math.abs(event.clientY - pressY);\n        if (travelled < DRAG_AFTER_PX) {\n          return;\n        }\n        isDragging = true;\n        grabY = event.clientY;\n        grabPosition = position;\n        lastMoveAt = event.timeStamp;\n        velocity = 0;\n        sleep();\n      }\n      const pulled = (grabY - event.clientY) / ITEM_PX;\n      const next = withGiveOf(grabPosition + pulled, lastIndex);\n      const sinceLast = event.timeStamp - lastMoveAt;\n      const elapsed = Math.max(sinceLast, 1);\n      const speed = (next - position) / elapsed;\n      velocity = velocity * 0.6 + speed * 0.4;\n      position = next;\n      lastMoveAt = event.timeStamp;\n      show();\n    },\n    release(event, isInstant) {\n      if (!isPressed) {\n        return;\n      }\n      const wasDragging = isDragging;\n      isPressed = false;\n      isDragging = false;\n      if (!wasDragging) {\n        const tapped = tappedIndexOf(event);\n        aimAt(tapped, isInstant);\n        return;\n      }\n      const stillFor = event.timeStamp - lastMoveAt;\n      if (stillFor > HELD_STILL_MS) {\n        velocity = 0;\n      }\n      const landing = Math.round(position + velocity * MOMENTUM_MS);\n      aimAt(landing, isInstant);\n    },\n    cancel(isInstant) {\n      const closest = Math.round(position);\n      isPressed = false;\n      isDragging = false;\n      aimAt(closest, isInstant);\n    },\n    dispose() {\n      sleep();\n    },\n  };\n}\n\nfunction distanceKmOf(from: GlobeLocation, to: GlobeLocation) {\n  const fromLatitude = radiansOf(from[0]);\n  const toLatitude = radiansOf(to[0]);\n  const latitudeGap = toLatitude - fromLatitude;\n  const longitudeGap = radiansOf(to[1] - from[1]);\n  const latitudeChord = Math.sin(latitudeGap / 2) ** 2;\n  const longitudeChord = Math.sin(longitudeGap / 2) ** 2;\n  const shrink = Math.cos(fromLatitude) * Math.cos(toLatitude);\n  const chord = latitudeChord + shrink * longitudeChord;\n  const halfChord = Math.sqrt(chord);\n  const angle = 2 * Math.asin(halfChord);\n  return EARTH_RADIUS_KM * angle;\n}\n\n/** A rough round trip between two places, from the distance alone. It is an estimate for a demo, never a measure. */\nexport function latencyMsOf(from: GlobeLocation, to: GlobeLocation) {\n  const distance = distanceKmOf(from, to);\n  const travel = distance / KM_PER_ROUND_TRIP_MS;\n  return Math.round(FIXED_LATENCY_MS + travel);\n}\n\nfunction directionOf([latitude, longitude]: GlobeLocation): Direction {\n  const latitudeAngle = radiansOf(latitude);\n  const longitudeAngle = radiansOf(longitude);\n  const ring = Math.cos(latitudeAngle);\n  const x = ring * Math.cos(longitudeAngle);\n  const y = ring * Math.sin(longitudeAngle);\n  const z = Math.sin(latitudeAngle);\n  return [x, y, z];\n}\n\nfunction locationOf([x, y, z]: Direction): GlobeLocation {\n  const flat = Math.hypot(x, y);\n  const latitude = degreesOf(Math.atan2(z, flat));\n  const longitude = degreesOf(Math.atan2(y, x));\n  return [rounded(latitude), rounded(longitude)];\n}\n\nfunction sumOf(first: Direction, second: Direction): Direction {\n  return [first[0] + second[0], first[1] + second[1], first[2] + second[2]];\n}\n\nfunction scaledOf([x, y, z]: Direction, factor: number): Direction {\n  return [x * factor, y * factor, z * factor];\n}\n\n/** A route with no length or no side has no direction there: it stays at zero instead of dividing by it. */\nfunction unitOf(direction: Direction): Direction {\n  const length = Math.hypot(...direction);\n  if (length === 0) {\n    return direction;\n  }\n  return scaledOf(direction, 1 / length);\n}\n\nfunction crossOf(first: Direction, second: Direction): Direction {\n  const x = first[1] * second[2] - first[2] * second[1];\n  const y = first[2] * second[0] - first[0] * second[2];\n  const z = first[0] * second[1] - first[1] * second[0];\n  return [x, y, z];\n}\n\n/** The pole of the circle the route runs along, taken on its southern side: looked at from there, the arc bows upwards. */\nfunction southSideOf(start: Direction, end: Direction): Direction {\n  const pole = unitOf(crossOf(start, end));\n  const isNorthern = pole[2] > 0;\n  if (isNorthern) {\n    return scaledOf(pole, -1);\n  }\n  return pole;\n}\n\n/** Where the globe turns to: the middle of the route seen from a little to its south, so both ends stay in sight when they can. */\nfunction viewOf(from: GlobeLocation, to: GlobeLocation): GlobeLocation {\n  const start = directionOf(from);\n  const end = directionOf(to);\n  const middle = unitOf(sumOf(start, end));\n  const side = southSideOf(start, end);\n  const aside = radiansOf(VIEW_ASIDE_DEG);\n  const fromMiddle = scaledOf(middle, Math.cos(aside));\n  const fromSide = scaledOf(side, Math.sin(aside));\n  const view = sumOf(fromMiddle, fromSide);\n  return locationOf(view);\n}\n\nconst KEY_STEPS: Record<string, number> = {\n  ArrowUp: -1,\n  ArrowDown: 1,\n};\n\nexport type RegionWheelProps = {\n  /** Where the visitor is. The route starts there. */\n  visitor: WheelPlace;\n  regions: WheelPlace[];\n  /** The region at the centre of the wheel. The wheel glides to it when it changes from outside. */\n  index: number;\n  /** Called as the wheel turns, each time another region reaches its centre. */\n  onIndexChange: (index: number) => void;\n  className?: string;\n};\n\nexport function RegionWheel({\n  visitor,\n  regions,\n  index,\n  onIndexChange,\n  className,\n}: RegionWheelProps) {\n  const hostRef = useRef<HTMLDivElement>(null);\n  const wheelRef = useRef<Wheel | null>(null);\n  const reportRef = useRef(onIndexChange);\n  const [startIndex] = useState(index);\n  const isStill = usePrefersReducedMotion();\n  const baseId = useId();\n  const lastIndex = regions.length - 1;\n  const region = regions[index];\n  const regionCount = regions.length;\n\n  useEffect(() => {\n    reportRef.current = onIndexChange;\n  }, [onIndexChange]);\n\n  useEffect(() => {\n    const host = hostRef.current;\n    if (!host) {\n      return;\n    }\n    const wheel = createWheel(host, startIndex, (nearest) =>\n      reportRef.current(nearest)\n    );\n    wheelRef.current = wheel;\n    return () => {\n      wheel.dispose();\n      wheelRef.current = null;\n    };\n  }, [startIndex, regionCount]);\n\n  useEffect(() => {\n    const wheel = wheelRef.current;\n    if (!wheel || wheel.isEcho(index)) {\n      return;\n    }\n    wheel.glideTo(index, isStill);\n  }, [index, isStill, regionCount]);\n\n  const route = useMemo(() => {\n    if (!region) {\n      return null;\n    }\n    const markers: GlobeMarker[] = [\n      { location: visitor.location, label: `Visitor in ${visitor.name}` },\n      { location: region.location, label: `Region ${region.name}` },\n    ];\n    const arcs: GlobeArc[] = [{ from: visitor.location, to: region.location }];\n    const focus = viewOf(visitor.location, region.location);\n    const latencyMs = latencyMsOf(visitor.location, region.location);\n    return { markers, arcs, focus, latencyMs };\n  }, [visitor, region]);\n\n  if (!region || !route) {\n    return null;\n  }\n\n  const names = regions.map((place) => place.name);\n\n  function optionIdOf(place: WheelPlace) {\n    return `${baseId}-${place.id}`;\n  }\n\n  function turnWithKeys(event: React.KeyboardEvent) {\n    const wheel = wheelRef.current;\n    if (!wheel) {\n      return;\n    }\n    const step = KEY_STEPS[event.key];\n    if (step !== undefined) {\n      event.preventDefault();\n      wheel.step(step, isStill);\n      return;\n    }\n    if (event.key === 'Home') {\n      event.preventDefault();\n      wheel.glideTo(0, isStill);\n      return;\n    }\n    if (event.key === 'End') {\n      event.preventDefault();\n      wheel.glideTo(lastIndex, isStill);\n    }\n  }\n\n  return (\n    <div className={cn('@container w-full max-w-[34rem]', className)}>\n      <div className='flex flex-col items-center gap-4 @md:flex-row @md:gap-6'>\n        <div\n          ref={hostRef}\n          role='listbox'\n          aria-label='Server region'\n          aria-activedescendant={optionIdOf(region)}\n          tabIndex={0}\n          onKeyDown={turnWithKeys}\n          onPointerDown={(event) => wheelRef.current?.press(event.nativeEvent)}\n          onPointerMove={(event) => wheelRef.current?.drag(event.nativeEvent)}\n          onPointerUp={(event) =>\n            wheelRef.current?.release(event.nativeEvent, isStill)\n          }\n          onPointerCancel={() => wheelRef.current?.cancel(isStill)}\n          className='bg-foreground/[0.03] focus-visible:ring-ring focus-visible:ring-offset-background relative h-44 w-full max-w-56 shrink-0 cursor-grab touch-none overflow-hidden rounded-xl outline-none select-none focus-visible:ring-2 focus-visible:ring-offset-2 active:cursor-grabbing @md:w-44'\n        >\n          <span\n            aria-hidden='true'\n            className='bg-foreground/[0.06] absolute inset-x-2 top-1/2 h-9 -translate-y-1/2 rounded-lg'\n          />\n          {regions.map((place, placeIndex) => (\n            <div\n              key={place.id}\n              id={optionIdOf(place)}\n              role='option'\n              aria-selected={placeIndex === index}\n              style={poseOf(placeIndex - startIndex)}\n              onClick={() => wheelRef.current?.glideTo(placeIndex, isStill)}\n              className='text-muted-foreground aria-selected:text-foreground absolute inset-x-0 top-1/2 -mt-[18px] flex h-9 cursor-pointer items-center justify-center text-[15px] font-medium transition-colors duration-150'\n            >\n              {place.name}\n            </div>\n          ))}\n        </div>\n        <div className='flex w-full min-w-0 flex-1 flex-col items-center gap-2'>\n          <Globe\n            focus={route.focus}\n            markers={route.markers}\n            arcs={route.arcs}\n            autoRotate={false}\n            label={`Route from ${visitor.name} to ${region.name}`}\n            className='max-w-56'\n          />\n          <div className='flex flex-col items-center'>\n            <p className='text-muted-foreground flex items-baseline gap-1 text-xs'>\n              {visitor.name} to\n              <WordRoll text={region.name} labels={names} />\n            </p>\n            <p className='text-2xl leading-8 font-semibold tabular-nums'>\n              <MotionNumber value={route.latencyMs} />\n              <span className='text-muted-foreground ms-1 text-sm font-normal'>\n                ms\n              </span>\n            </p>\n            <p className='text-muted-foreground text-xs'>\n              Estimate for this demo\n            </p>\n          </div>\n        </div>\n      </div>\n    </div>\n  );\n}\n\nconst VISITOR: WheelPlace = {\n  id: 'lagos',\n  name: 'Lagos',\n  location: [6.5, 3.4],\n};\n\nconst REGIONS: WheelPlace[] = [\n  { id: 'oregon', name: 'Oregon', location: [45.5, -122.7] },\n  { id: 'virginia', name: 'Virginia', location: [38.9, -77.5] },\n  { id: 'sao-paulo', name: 'São Paulo', location: [-23.5, -46.6] },\n  { id: 'dublin', name: 'Dublin', location: [53.3, -6.3] },\n  { id: 'frankfurt', name: 'Frankfurt', location: [50.1, 8.7] },\n  { id: 'cape-town', name: 'Cape Town', location: [-33.9, 18.4] },\n  { id: 'mumbai', name: 'Mumbai', location: [19.1, 72.9] },\n  { id: 'singapore', name: 'Singapore', location: [1.35, 103.8] },\n  { id: 'tokyo', name: 'Tokyo', location: [35.7, 139.7] },\n];\n\nconst START_INDEX = 4;\n\nconst TOUR = [8, 2, 5, 1];\n\nconst TOUR_HOLD_MS = 2800;\n\nexport default function Illustration11() {\n  const [index, setIndex] = useState(START_INDEX);\n  const steps: AutoplayStep[] = TOUR.map((stop) => ({\n    after: TOUR_HOLD_MS,\n    run: () => setIndex(stop),\n  }));\n  const { ref, isAutoplaying } = useAutoplay(steps, {\n    loopAfter: TOUR_HOLD_MS,\n    onReset: () => setIndex(START_INDEX),\n  });\n  const region = REGIONS[index];\n  const latencyMs = latencyMsOf(VISITOR.location, region.location);\n  const announcement = `${region.name}, about ${latencyMs} milliseconds from ${VISITOR.name}`;\n\n  return (\n    <div ref={ref} className='flex w-full justify-center'>\n      <RegionWheel\n        visitor={VISITOR}\n        regions={REGIONS}\n        index={index}\n        onIndexChange={setIndex}\n      />\n      <LiveRegion message={spokenUnless(isAutoplaying, announcement)} />\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/illustration/illustration-11.tsx"
    },
    {
      "path": "registry/ndeko/components/illustration/_parts/geometry.ts",
      "content": "export type ScenePoint = {\n  /** Share of the stage width, from 0 to 1. */\n  x: number;\n  /** Share of the stage height, from 0 to 1. */\n  y: number;\n};\n\nexport type SceneSpan = {\n  /** Length of the line as a percentage of the stage width. */\n  lengthPercent: number;\n  /** Angle of the line in degrees, clockwise from the right, as CSS turns it. */\n  angleDeg: number;\n};\n\nconst HALF_TURN_DEG = 180;\n\nconst FULL_TURN_DEG = 360;\n\n/**\n * Two engines can disagree on the last digit of a sine. A value written into a style is rounded, so\n * the server and the browser print the same text.\n */\nexport function rounded(value: number) {\n  const hundredths = Math.round(value * 100);\n  return hundredths / 100;\n}\n\nexport function percentOf(share: number) {\n  const percent = rounded(share * 100);\n  return `${percent}%`;\n}\n\nexport function degreesOf(radians: number) {\n  return (radians * HALF_TURN_DEG) / Math.PI;\n}\n\nexport function radiansOf(degrees: number) {\n  return (degrees * Math.PI) / HALF_TURN_DEG;\n}\n\n/** The angle equal to `target` that is closest to `current`, so a turn towards it goes the short way round. */\nexport function nearestAngleOf(target: number, current: number) {\n  const difference = target - current;\n  const turns = Math.round(difference / FULL_TURN_DEG);\n  const wrapped = difference - FULL_TURN_DEG * turns;\n  return current + wrapped;\n}\n\n/** The line between two points of a stage that is `aspect` times wider than it is tall. */\nexport function spanBetween(\n  from: ScenePoint,\n  to: ScenePoint,\n  aspect: number\n): SceneSpan {\n  const acrossShare = to.x - from.x;\n  const downShare = to.y - from.y;\n  const downInWidths = downShare / aspect;\n  const lengthInWidths = Math.hypot(acrossShare, downInWidths);\n  const angle = Math.atan2(downInWidths, acrossShare);\n  const degrees = degreesOf(angle);\n  return {\n    lengthPercent: rounded(lengthInWidths * 100),\n    angleDeg: rounded(degrees),\n  };\n}\n\n/** Where a tile centred on a point of the stage goes: its `left` and `top`. */\nexport function placeOf(point: ScenePoint) {\n  return { left: percentOf(point.x), top: percentOf(point.y) };\n}\n",
      "type": "registry:component",
      "target": "components/illustration/_parts/geometry.ts"
    }
  ],
  "categories": [
    "components",
    "illustration"
  ],
  "type": "registry:component"
}