Back to the library

Stroke gesture — lasso select

Variant: Lasso select

Lasso-selecting points on a scatter plot, where the outcome is shown before the user commits to it. Every 40ms the drawn stroke is closed with a straight line back to its start and tested against the points, and any point inside gets a preview ring in 96ms on ease-out. The rings gather as the loop wraps round the cluster, so the user can see what they are about to take while they can still change course. The trail’s vertices are the cursor’s own samples, so the stroke ends exactly at the cursor tip. Letting go short of the start does not cancel. The loop closes itself with a dashed chord in 120ms, dashed because nobody drew it, and the chord, not the curve the user might have meant, is the edge: the point sitting in that gap stays out. Every point inside is then selected on the same frame, along with the count, because a selection is one set chosen at once and should not land one point after another. The outline leaves 200ms later in 180ms and the selection stays, until a click on empty space clears it in 150ms. Under reduced motion the cursor goes and the loop fades in over the time it would have taken to draw, so the previews still have a visible cause, and the commit keeps its timing. Reach for it for scatter plots, canvases, maps and photo grids, anywhere the things to pick are scattered in two dimensions.

svgline-drawinggesturedatachartcontrolloop

The source

A complete HTML document. Paste it into an empty .html file and it plays — no stylesheet, script, font, or image to fetch.

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Stroke gesture — lasso select</title>
    <style>
      :root {
        /* Neutrals — fixed, never remixed. */
        --ivory: #faf9f5;
        --paper: #ffffff;
        --oat: #e3dacc;
        --slate: #141413;

        /* Knobs — the remix API. A knob exists iff declared here and used below. */
        --hue: 38.8;
        --lift: 0;
        --chroma: 1;
        --round: 1;
        --speed: 1;

        /* Accents — derived from the knobs with the family's offsets baked in,
           so one hue roll moves them together. Defaults reproduce the original hex. */
        --clay: oklch(calc(0.6724 + var(--lift)) calc(0.1308 * var(--chroma)) var(--hue));
        --clay-d: oklch(calc(0.5797 + var(--lift)) calc(0.127 * var(--chroma)) var(--hue));
        --olive: oklch(
          calc(0.6118 + var(--lift)) calc(0.0713 * var(--chroma)) calc(var(--hue) + 88.3)
        );
        --rust: oklch(
          calc(0.5408 + var(--lift)) calc(0.1357 * var(--chroma)) calc(var(--hue) - 10.3)
        );

        /* Clock — 6s (1% = 60ms). 1.5s of drawing, 120ms to close the loop, the
           selection committed on the frame it closes, the outline gone 200ms
           later, and the selection held until a click on empty space clears it. */
        --cycle: 6s;
        --t: calc(var(--cycle) / var(--speed));

        --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
        --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);

        --_ink: color-mix(in srgb, var(--slate) 80%, transparent);
        --_dot: color-mix(in oklch, var(--slate) 34%, var(--paper));
        --_lasso: color-mix(in oklch, var(--slate) 55%, var(--paper));
        --_area: color-mix(in srgb, var(--clay) 9%, transparent);
      }

      * {
        box-sizing: border-box;
        margin: 0;
        padding: 0;
      }

      body {
        min-height: 100vh;
        display: grid;
        place-items: center;
        padding: clamp(10px, 3vw, 28px);
        background: var(--ivory);
        font-family:
          system-ui,
          -apple-system,
          'Segoe UI',
          Roboto,
          sans-serif;
      }

      .card {
        width: min(380px, 92vw);
        border: 1px solid var(--oat);
        border-radius: calc(14px * var(--round));
        background: var(--paper);
      }

      .card svg {
        display: block;
        width: 100%;
        height: auto;
      }

      .axis {
        stroke: var(--oat);
        stroke-width: 1;
      }

      .readout text {
        font-size: 12.5px;
        font-weight: 500;
        fill: var(--_ink);
        font-variant-numeric: tabular-nums;
      }

      .r-all {
        animation: r-all var(--t) infinite;
      }

      .r-sel {
        opacity: 0;
        animation: r-sel var(--t) infinite;
      }

      .pt {
        fill: var(--_dot);
      }

      .ring {
        fill: none;
        stroke-width: 1.4;
        opacity: 0;
        transform-box: fill-box;
        transform-origin: center;
      }

      .p0 .ring {
        animation: ring-0 var(--t) infinite;
      }

      .p0 .pt {
        animation: pt-0 var(--t) infinite;
      }

      .p1 .ring {
        animation: ring-1 var(--t) infinite;
      }

      .p1 .pt {
        animation: pt-1 var(--t) infinite;
      }

      .p2 .ring {
        animation: ring-2 var(--t) infinite;
      }

      .p2 .pt {
        animation: pt-2 var(--t) infinite;
      }

      .p3 .ring {
        animation: ring-3 var(--t) infinite;
      }

      .p3 .pt {
        animation: pt-3 var(--t) infinite;
      }

      .p4 .ring {
        animation: ring-4 var(--t) infinite;
      }

      .p4 .pt {
        animation: pt-4 var(--t) infinite;
      }

      .p5 .ring {
        animation: ring-5 var(--t) infinite;
      }

      .p5 .pt {
        animation: pt-5 var(--t) infinite;
      }

      .p6 .ring {
        animation: ring-6 var(--t) infinite;
      }

      .p6 .pt {
        animation: pt-6 var(--t) infinite;
      }

      /* The trail's vertices are the pointer's own samples, 40ms apart, and
         both run linear between them — so the pen tip and the cursor tip are
         the same point on every frame, not two animations that agree. */
      .trail,
      .chord {
        fill: none;
        stroke: var(--_lasso);
        stroke-width: 1.5;
        stroke-linecap: round;
        stroke-linejoin: round;
      }

      /* Parked at 102, not 100: at exactly 100 the round cap paints a speck. */
      .trail {
        stroke-dasharray: 100 200;
        animation: trail var(--t) infinite linear;
      }

      /* Releasing short of the start does not cancel: the lasso closes itself
         with a straight chord. The chord, not the bulge the user might have
         meant, is the boundary — so a point in that gap stays out. */
      .chord {
        stroke-dasharray: 3 3.5;
        opacity: 0;
        animation: chord var(--t) infinite;
      }

      .area {
        fill: var(--_area);
        opacity: 0;
        animation: area var(--t) infinite;
      }

      .pointer {
        opacity: 0;
        animation: pointer var(--t) infinite linear;
      }

      .pointer path {
        fill: var(--slate);
        stroke: var(--paper);
        stroke-width: 1.25;
        stroke-linejoin: round;
      }

      @keyframes ring-0 {
        0% {
          opacity: 0;
          transform: scale(0.7);
          stroke: var(--clay);
        }
        21% {
          opacity: 0;
          transform: scale(0.7);
          stroke: var(--clay);
          animation-timing-function: var(--ease-out);
        }
        22.6% {
          opacity: 0.7;
          transform: scale(1);
          stroke: var(--clay);
        }
        34% {
          opacity: 0.7;
          transform: scale(1);
          stroke: var(--clay);
          animation-timing-function: ease;
        }
        36% {
          opacity: 1;
          transform: scale(1);
          stroke: var(--clay-d);
        }
        79% {
          opacity: 1;
          transform: scale(1);
          stroke: var(--clay-d);
          animation-timing-function: var(--ease-out);
        }
        81.5% {
          opacity: 0;
          transform: scale(0.7);
          stroke: var(--clay);
        }
        100% {
          opacity: 0;
          transform: scale(0.7);
          stroke: var(--clay);
        }
      }

      @keyframes pt-0 {
        0% {
          fill: var(--_dot);
        }
        21% {
          fill: var(--_dot);
          animation-timing-function: var(--ease-out);
        }
        22.6% {
          fill: var(--_dot);
        }
        34% {
          fill: var(--_dot);
          animation-timing-function: ease;
        }
        36% {
          fill: var(--clay-d);
        }
        79% {
          fill: var(--clay-d);
          animation-timing-function: var(--ease-out);
        }
        81.5% {
          fill: var(--_dot);
        }
        100% {
          fill: var(--_dot);
        }
      }

      @keyframes ring-1 {
        0% {
          opacity: 0;
          transform: scale(0.7);
          stroke: var(--clay);
        }
        23.67% {
          opacity: 0;
          transform: scale(0.7);
          stroke: var(--clay);
          animation-timing-function: var(--ease-out);
        }
        25.27% {
          opacity: 0.7;
          transform: scale(1);
          stroke: var(--clay);
        }
        34% {
          opacity: 0.7;
          transform: scale(1);
          stroke: var(--clay);
          animation-timing-function: ease;
        }
        36% {
          opacity: 1;
          transform: scale(1);
          stroke: var(--clay-d);
        }
        79% {
          opacity: 1;
          transform: scale(1);
          stroke: var(--clay-d);
          animation-timing-function: var(--ease-out);
        }
        81.5% {
          opacity: 0;
          transform: scale(0.7);
          stroke: var(--clay);
        }
        100% {
          opacity: 0;
          transform: scale(0.7);
          stroke: var(--clay);
        }
      }

      @keyframes pt-1 {
        0% {
          fill: var(--_dot);
        }
        23.67% {
          fill: var(--_dot);
          animation-timing-function: var(--ease-out);
        }
        25.27% {
          fill: var(--_dot);
        }
        34% {
          fill: var(--_dot);
          animation-timing-function: ease;
        }
        36% {
          fill: var(--clay-d);
        }
        79% {
          fill: var(--clay-d);
          animation-timing-function: var(--ease-out);
        }
        81.5% {
          fill: var(--_dot);
        }
        100% {
          fill: var(--_dot);
        }
      }

      @keyframes ring-2 {
        0% {
          opacity: 0;
          transform: scale(0.7);
          stroke: var(--clay);
        }
        18.33% {
          opacity: 0;
          transform: scale(0.7);
          stroke: var(--clay);
          animation-timing-function: var(--ease-out);
        }
        19.93% {
          opacity: 0.7;
          transform: scale(1);
          stroke: var(--clay);
        }
        34% {
          opacity: 0.7;
          transform: scale(1);
          stroke: var(--clay);
          animation-timing-function: ease;
        }
        36% {
          opacity: 1;
          transform: scale(1);
          stroke: var(--clay-d);
        }
        79% {
          opacity: 1;
          transform: scale(1);
          stroke: var(--clay-d);
          animation-timing-function: var(--ease-out);
        }
        81.5% {
          opacity: 0;
          transform: scale(0.7);
          stroke: var(--clay);
        }
        100% {
          opacity: 0;
          transform: scale(0.7);
          stroke: var(--clay);
        }
      }

      @keyframes pt-2 {
        0% {
          fill: var(--_dot);
        }
        18.33% {
          fill: var(--_dot);
          animation-timing-function: var(--ease-out);
        }
        19.93% {
          fill: var(--_dot);
        }
        34% {
          fill: var(--_dot);
          animation-timing-function: ease;
        }
        36% {
          fill: var(--clay-d);
        }
        79% {
          fill: var(--clay-d);
          animation-timing-function: var(--ease-out);
        }
        81.5% {
          fill: var(--_dot);
        }
        100% {
          fill: var(--_dot);
        }
      }

      @keyframes ring-3 {
        0% {
          opacity: 0;
          transform: scale(0.7);
          stroke: var(--clay);
        }
        21.67% {
          opacity: 0;
          transform: scale(0.7);
          stroke: var(--clay);
          animation-timing-function: var(--ease-out);
        }
        23.27% {
          opacity: 0.7;
          transform: scale(1);
          stroke: var(--clay);
        }
        34% {
          opacity: 0.7;
          transform: scale(1);
          stroke: var(--clay);
          animation-timing-function: ease;
        }
        36% {
          opacity: 1;
          transform: scale(1);
          stroke: var(--clay-d);
        }
        79% {
          opacity: 1;
          transform: scale(1);
          stroke: var(--clay-d);
          animation-timing-function: var(--ease-out);
        }
        81.5% {
          opacity: 0;
          transform: scale(0.7);
          stroke: var(--clay);
        }
        100% {
          opacity: 0;
          transform: scale(0.7);
          stroke: var(--clay);
        }
      }

      @keyframes pt-3 {
        0% {
          fill: var(--_dot);
        }
        21.67% {
          fill: var(--_dot);
          animation-timing-function: var(--ease-out);
        }
        23.27% {
          fill: var(--_dot);
        }
        34% {
          fill: var(--_dot);
          animation-timing-function: ease;
        }
        36% {
          fill: var(--clay-d);
        }
        79% {
          fill: var(--clay-d);
          animation-timing-function: var(--ease-out);
        }
        81.5% {
          fill: var(--_dot);
        }
        100% {
          fill: var(--_dot);
        }
      }

      @keyframes ring-4 {
        0% {
          opacity: 0;
          transform: scale(0.7);
          stroke: var(--clay);
        }
        19.67% {
          opacity: 0;
          transform: scale(0.7);
          stroke: var(--clay);
          animation-timing-function: var(--ease-out);
        }
        21.27% {
          opacity: 0.7;
          transform: scale(1);
          stroke: var(--clay);
        }
        34% {
          opacity: 0.7;
          transform: scale(1);
          stroke: var(--clay);
          animation-timing-function: ease;
        }
        36% {
          opacity: 1;
          transform: scale(1);
          stroke: var(--clay-d);
        }
        79% {
          opacity: 1;
          transform: scale(1);
          stroke: var(--clay-d);
          animation-timing-function: var(--ease-out);
        }
        81.5% {
          opacity: 0;
          transform: scale(0.7);
          stroke: var(--clay);
        }
        100% {
          opacity: 0;
          transform: scale(0.7);
          stroke: var(--clay);
        }
      }

      @keyframes pt-4 {
        0% {
          fill: var(--_dot);
        }
        19.67% {
          fill: var(--_dot);
          animation-timing-function: var(--ease-out);
        }
        21.27% {
          fill: var(--_dot);
        }
        34% {
          fill: var(--_dot);
          animation-timing-function: ease;
        }
        36% {
          fill: var(--clay-d);
        }
        79% {
          fill: var(--clay-d);
          animation-timing-function: var(--ease-out);
        }
        81.5% {
          fill: var(--_dot);
        }
        100% {
          fill: var(--_dot);
        }
      }

      @keyframes ring-5 {
        0% {
          opacity: 0;
          transform: scale(0.7);
          stroke: var(--clay);
        }
        24.33% {
          opacity: 0;
          transform: scale(0.7);
          stroke: var(--clay);
          animation-timing-function: var(--ease-out);
        }
        25.93% {
          opacity: 0.7;
          transform: scale(1);
          stroke: var(--clay);
        }
        34% {
          opacity: 0.7;
          transform: scale(1);
          stroke: var(--clay);
          animation-timing-function: ease;
        }
        36% {
          opacity: 1;
          transform: scale(1);
          stroke: var(--clay-d);
        }
        79% {
          opacity: 1;
          transform: scale(1);
          stroke: var(--clay-d);
          animation-timing-function: var(--ease-out);
        }
        81.5% {
          opacity: 0;
          transform: scale(0.7);
          stroke: var(--clay);
        }
        100% {
          opacity: 0;
          transform: scale(0.7);
          stroke: var(--clay);
        }
      }

      @keyframes pt-5 {
        0% {
          fill: var(--_dot);
        }
        24.33% {
          fill: var(--_dot);
          animation-timing-function: var(--ease-out);
        }
        25.93% {
          fill: var(--_dot);
        }
        34% {
          fill: var(--_dot);
          animation-timing-function: ease;
        }
        36% {
          fill: var(--clay-d);
        }
        79% {
          fill: var(--clay-d);
          animation-timing-function: var(--ease-out);
        }
        81.5% {
          fill: var(--_dot);
        }
        100% {
          fill: var(--_dot);
        }
      }

      @keyframes ring-6 {
        0% {
          opacity: 0;
          transform: scale(0.7);
          stroke: var(--clay);
        }
        21.67% {
          opacity: 0;
          transform: scale(0.7);
          stroke: var(--clay);
          animation-timing-function: var(--ease-out);
        }
        23.27% {
          opacity: 0.7;
          transform: scale(1);
          stroke: var(--clay);
        }
        34% {
          opacity: 0.7;
          transform: scale(1);
          stroke: var(--clay);
          animation-timing-function: ease;
        }
        36% {
          opacity: 1;
          transform: scale(1);
          stroke: var(--clay-d);
        }
        79% {
          opacity: 1;
          transform: scale(1);
          stroke: var(--clay-d);
          animation-timing-function: var(--ease-out);
        }
        81.5% {
          opacity: 0;
          transform: scale(0.7);
          stroke: var(--clay);
        }
        100% {
          opacity: 0;
          transform: scale(0.7);
          stroke: var(--clay);
        }
      }

      @keyframes pt-6 {
        0% {
          fill: var(--_dot);
        }
        21.67% {
          fill: var(--_dot);
          animation-timing-function: var(--ease-out);
        }
        23.27% {
          fill: var(--_dot);
        }
        34% {
          fill: var(--_dot);
          animation-timing-function: ease;
        }
        36% {
          fill: var(--clay-d);
        }
        79% {
          fill: var(--clay-d);
          animation-timing-function: var(--ease-out);
        }
        81.5% {
          fill: var(--_dot);
        }
        100% {
          fill: var(--_dot);
        }
      }

      @keyframes trail {
        0% {
          stroke-dashoffset: 102;
          opacity: 1;
        }
        7% {
          stroke-dashoffset: 102;
          opacity: 1;
        }
        7.67% {
          stroke-dashoffset: 99.07;
          opacity: 1;
        }
        8.33% {
          stroke-dashoffset: 97.93;
          opacity: 1;
        }
        9% {
          stroke-dashoffset: 96.57;
          opacity: 1;
        }
        9.67% {
          stroke-dashoffset: 94.94;
          opacity: 1;
        }
        10.33% {
          stroke-dashoffset: 92.98;
          opacity: 1;
        }
        11% {
          stroke-dashoffset: 90.62;
          opacity: 1;
        }
        11.67% {
          stroke-dashoffset: 87.83;
          opacity: 1;
        }
        12.33% {
          stroke-dashoffset: 84.66;
          opacity: 1;
        }
        13% {
          stroke-dashoffset: 81.29;
          opacity: 1;
        }
        13.67% {
          stroke-dashoffset: 77.95;
          opacity: 1;
        }
        14.33% {
          stroke-dashoffset: 74.76;
          opacity: 1;
        }
        15% {
          stroke-dashoffset: 71.64;
          opacity: 1;
        }
        15.67% {
          stroke-dashoffset: 68.38;
          opacity: 1;
        }
        16.33% {
          stroke-dashoffset: 64.92;
          opacity: 1;
        }
        17% {
          stroke-dashoffset: 61.39;
          opacity: 1;
        }
        17.67% {
          stroke-dashoffset: 57.99;
          opacity: 1;
        }
        18.33% {
          stroke-dashoffset: 54.75;
          opacity: 1;
        }
        19% {
          stroke-dashoffset: 51.59;
          opacity: 1;
        }
        19.67% {
          stroke-dashoffset: 48.51;
          opacity: 1;
        }
        20.33% {
          stroke-dashoffset: 45.59;
          opacity: 1;
        }
        21% {
          stroke-dashoffset: 42.69;
          opacity: 1;
        }
        21.67% {
          stroke-dashoffset: 39.41;
          opacity: 1;
        }
        22.33% {
          stroke-dashoffset: 35.76;
          opacity: 1;
        }
        23% {
          stroke-dashoffset: 32.13;
          opacity: 1;
        }
        23.67% {
          stroke-dashoffset: 28.76;
          opacity: 1;
        }
        24.33% {
          stroke-dashoffset: 25.58;
          opacity: 1;
        }
        25% {
          stroke-dashoffset: 22.4;
          opacity: 1;
        }
        25.67% {
          stroke-dashoffset: 19.19;
          opacity: 1;
        }
        26.33% {
          stroke-dashoffset: 16.03;
          opacity: 1;
        }
        27% {
          stroke-dashoffset: 13.07;
          opacity: 1;
        }
        27.67% {
          stroke-dashoffset: 10.41;
          opacity: 1;
        }
        28.33% {
          stroke-dashoffset: 8.06;
          opacity: 1;
        }
        29% {
          stroke-dashoffset: 6.01;
          opacity: 1;
        }
        29.67% {
          stroke-dashoffset: 4.2;
          opacity: 1;
        }
        30.33% {
          stroke-dashoffset: 2.6;
          opacity: 1;
        }
        31% {
          stroke-dashoffset: 1.2;
          opacity: 1;
        }
        31.67% {
          stroke-dashoffset: 0;
          opacity: 1;
        }
        37.33% {
          stroke-dashoffset: 0;
          opacity: 1;
          animation-timing-function: var(--ease-out);
        }
        40.33% {
          stroke-dashoffset: 0;
          opacity: 0;
        }
        40.35% {
          stroke-dashoffset: 102;
          opacity: 0;
        }
        100% {
          stroke-dashoffset: 102;
          opacity: 0;
        }
      }

      @keyframes chord {
        0% {
          opacity: 0;
        }
        32% {
          opacity: 0;
          animation-timing-function: var(--ease-out);
        }
        34% {
          opacity: 1;
        }
        37.33% {
          opacity: 1;
          animation-timing-function: var(--ease-out);
        }
        40.33% {
          opacity: 0;
        }
        100% {
          opacity: 0;
        }
      }

      @keyframes area {
        0% {
          opacity: 0;
        }
        32% {
          opacity: 0;
          animation-timing-function: var(--ease-out);
        }
        34% {
          opacity: 1;
        }
        37.33% {
          opacity: 1;
          animation-timing-function: var(--ease-out);
        }
        40.33% {
          opacity: 0;
        }
        100% {
          opacity: 0;
        }
      }

      @keyframes pointer {
        0% {
          opacity: 0;
          transform: translate(69.5px, 121.1px) scale(1);
        }
        1% {
          opacity: 0;
          transform: translate(69.5px, 121.1px) scale(1);
          animation-timing-function: var(--ease-out);
        }
        5.5% {
          opacity: 1;
          transform: translate(95.5px, 91.1px) scale(1);
          animation-timing-function: var(--ease-out);
        }
        6.2% {
          opacity: 1;
          transform: translate(95.5px, 91.1px) scale(1);
          animation-timing-function: var(--ease-out);
        }
        7% {
          opacity: 1;
          transform: translate(95.5px, 91.1px) scale(0.9);
        }
        7.67% {
          opacity: 1;
          transform: translate(96.4px, 88.4px) scale(0.9);
        }
        8.33% {
          opacity: 1;
          transform: translate(97.8px, 85.2px) scale(0.9);
        }
        9% {
          opacity: 1;
          transform: translate(99.8px, 81.6px) scale(0.9);
        }
        9.67% {
          opacity: 1;
          transform: translate(102.9px, 77.7px) scale(0.9);
        }
        10.33% {
          opacity: 1;
          transform: translate(107.4px, 73.7px) scale(0.9);
        }
        11% {
          opacity: 1;
          transform: translate(113.6px, 70.1px) scale(0.9);
        }
        11.67% {
          opacity: 1;
          transform: translate(121.7px, 67.5px) scale(0.9);
        }
        12.33% {
          opacity: 1;
          transform: translate(131.3px, 66.1px) scale(0.9);
        }
        13% {
          opacity: 1;
          transform: translate(141.5px, 66.2px) scale(0.9);
        }
        13.67% {
          opacity: 1;
          transform: translate(151.7px, 67.3px) scale(0.9);
        }
        14.33% {
          opacity: 1;
          transform: translate(161.3px, 68.7px) scale(0.9);
        }
        15% {
          opacity: 1;
          transform: translate(170.7px, 69.9px) scale(0.9);
        }
        15.67% {
          opacity: 1;
          transform: translate(180.6px, 70.9px) scale(0.9);
        }
        16.33% {
          opacity: 1;
          transform: translate(191px, 72.6px) scale(0.9);
        }
        17% {
          opacity: 1;
          transform: translate(201.3px, 75.7px) scale(0.9);
        }
        17.67% {
          opacity: 1;
          transform: translate(210.6px, 80.3px) scale(0.9);
        }
        18.33% {
          opacity: 1;
          transform: translate(218.5px, 86.3px) scale(0.9);
        }
        19% {
          opacity: 1;
          transform: translate(225.2px, 93.2px) scale(0.9);
        }
        19.67% {
          opacity: 1;
          transform: translate(230.4px, 101.1px) scale(0.9);
        }
        20.33% {
          opacity: 1;
          transform: translate(232.7px, 109.6px) scale(0.9);
        }
        21% {
          opacity: 1;
          transform: translate(230.6px, 118.2px) scale(0.9);
        }
        21.67% {
          opacity: 1;
          transform: translate(224px, 125.7px) scale(0.9);
        }
        22.33% {
          opacity: 1;
          transform: translate(214.4px, 131.4px) scale(0.9);
        }
        23% {
          opacity: 1;
          transform: translate(204.2px, 135.6px) scale(0.9);
        }
        23.67% {
          opacity: 1;
          transform: translate(194.6px, 139.1px) scale(0.9);
        }
        24.33% {
          opacity: 1;
          transform: translate(185.5px, 142.5px) scale(0.9);
        }
        25% {
          opacity: 1;
          transform: translate(176.2px, 145.5px) scale(0.9);
        }
        25.67% {
          opacity: 1;
          transform: translate(166.6px, 147.4px) scale(0.9);
        }
        26.33% {
          opacity: 1;
          transform: translate(157px, 147.9px) scale(0.9);
        }
        27% {
          opacity: 1;
          transform: translate(148px, 146.9px) scale(0.9);
        }
        27.67% {
          opacity: 1;
          transform: translate(140.2px, 145px) scale(0.9);
        }
        28.33% {
          opacity: 1;
          transform: translate(133.4px, 142.5px) scale(0.9);
        }
        29% {
          opacity: 1;
          transform: translate(127.7px, 140px) scale(0.9);
        }
        29.67% {
          opacity: 1;
          transform: translate(122.7px, 137.6px) scale(0.9);
        }
        30.33% {
          opacity: 1;
          transform: translate(118.4px, 135.5px) scale(0.9);
        }
        31% {
          opacity: 1;
          transform: translate(114.6px, 133.5px) scale(0.9);
        }
        31.67% {
          opacity: 1;
          transform: translate(111.4px, 131.7px) scale(0.9);
        }
        32.02% {
          opacity: 1;
          transform: translate(111.4px, 131.7px) scale(0.9);
          animation-timing-function: var(--ease-out);
        }
        34% {
          opacity: 1;
          transform: translate(111.4px, 131.7px) scale(1);
          animation-timing-function: var(--ease-in-out);
        }
        42.33% {
          opacity: 1;
          transform: translate(111.4px, 131.7px) scale(1);
          animation-timing-function: var(--ease-in-out);
        }
        51% {
          opacity: 1;
          transform: translate(236px, 108px) scale(1);
          animation-timing-function: var(--ease-in-out);
        }
        70% {
          opacity: 1;
          transform: translate(236px, 108px) scale(1);
          animation-timing-function: var(--ease-in-out);
        }
        77% {
          opacity: 1;
          transform: translate(244px, 124px) scale(1);
          animation-timing-function: var(--ease-out);
        }
        78.2% {
          opacity: 1;
          transform: translate(244px, 124px) scale(0.9);
          animation-timing-function: var(--ease-out);
        }
        80.6% {
          opacity: 1;
          transform: translate(244px, 124px) scale(1);
          animation-timing-function: var(--ease-in-out);
        }
        86% {
          opacity: 1;
          transform: translate(244px, 124px) scale(1);
          animation-timing-function: var(--ease-in-out);
        }
        94% {
          opacity: 0;
          transform: translate(262px, 186px) scale(1);
        }
        100% {
          opacity: 0;
          transform: translate(262px, 186px) scale(1);
        }
      }

      @keyframes r-all {
        0% {
          opacity: 1;
        }
        34% {
          opacity: 1;
          animation-timing-function: ease;
        }
        35.5% {
          opacity: 0;
        }
        80.5% {
          opacity: 0;
          animation-timing-function: ease;
        }
        82.83% {
          opacity: 1;
        }
        100% {
          opacity: 1;
        }
      }

      @keyframes r-sel {
        0% {
          opacity: 0;
        }
        35.5% {
          opacity: 0;
          animation-timing-function: ease;
        }
        37.83% {
          opacity: 1;
        }
        79% {
          opacity: 1;
          animation-timing-function: ease;
        }
        80.5% {
          opacity: 0;
        }
        100% {
          opacity: 0;
        }
      }

      @media (prefers-reduced-motion: reduce) {
        /* Same score, 1.6x slower. The cursor's travel and the pen are the
           motion that goes; the loop fades in whole over the time it would
           have taken to draw, so the previews still have a visible cause. */
        :root {
          --t: calc(var(--cycle) * 1.6 / var(--speed));
        }

        .pointer {
          display: none;
        }

        .trail {
          stroke-dashoffset: 0;
          animation: trail-calm var(--t) infinite;
        }

        @keyframes trail-calm {
          0% {
            opacity: 0;
          }
          7% {
            opacity: 0;
            animation-timing-function: ease;
          }
          32% {
            opacity: 1;
          }
          37.33% {
            opacity: 1;
            animation-timing-function: var(--ease-out);
          }
          40.33% {
            opacity: 0;
          }
          100% {
            opacity: 0;
          }
        }
      }
    </style>
  </head>
  <body>
    <div class="card">
      <svg
        viewBox="0 0 300 180"
        role="img"
        aria-label="A cursor draws a freehand lasso around a cluster of points on a scatter plot. Points inside the loop show a preview ring while it is drawn; on release the loop closes itself with a straight chord, 7 points are selected at once, and the count reads 7 of 20 selected until a click on empty space clears it"
      >
        <line class="axis" x1="24" y1="170" x2="284" y2="170" />
        <line class="axis" x1="24" y1="34" x2="24" y2="170" />
        <g class="readout">
          <text class="r-all" x="24" y="22">20 points</text>
          <text class="r-sel" x="24" y="22">7 of 20 selected</text>
        </g>
        <polygon
          class="area"
          points="95.5,91.1 96.4,88.4 97.8,85.2 99.8,81.6 102.9,77.7 107.4,73.7 113.6,70.1 121.7,67.5 131.3,66.1 141.5,66.2 151.7,67.3 161.3,68.7 170.7,69.9 180.6,70.9 191,72.6 201.3,75.7 210.6,80.3 218.5,86.3 225.2,93.2 230.4,101.1 232.7,109.6 230.6,118.2 224,125.7 214.4,131.4 204.2,135.6 194.6,139.1 185.5,142.5 176.2,145.5 166.6,147.4 157,147.9 148,146.9 140.2,145 133.4,142.5 127.7,140 122.7,137.6 118.4,135.5 114.6,133.5 111.4,131.7"
        />
        <g class="dots">
          <g class="p0">
            <circle class="ring" cx="130" cy="96" r="7" />
            <circle class="pt" cx="130" cy="96" r="3.5" />
          </g>
          <g class="p1">
            <circle class="ring" cx="147" cy="114" r="7" />
            <circle class="pt" cx="147" cy="114" r="3.5" />
          </g>
          <g class="p2">
            <circle class="ring" cx="166" cy="88" r="7" />
            <circle class="pt" cx="166" cy="88" r="3.5" />
          </g>
          <g class="p3">
            <circle class="ring" cx="183" cy="109" r="7" />
            <circle class="pt" cx="183" cy="109" r="3.5" />
          </g>
          <g class="p4">
            <circle class="ring" cx="198" cy="97" r="7" />
            <circle class="pt" cx="198" cy="97" r="3.5" />
          </g>
          <g class="p5">
            <circle class="ring" cx="159" cy="126" r="7" />
            <circle class="pt" cx="159" cy="126" r="3.5" />
          </g>
          <g class="p6">
            <circle class="ring" cx="212" cy="120" r="7" />
            <circle class="pt" cx="212" cy="120" r="3.5" />
          </g>
          <g class="p7">
            <circle class="ring" cx="97" cy="113" r="7" />
            <circle class="pt" cx="97" cy="113" r="3.5" />
          </g>
          <g class="p8">
            <circle class="ring" cx="48" cy="72" r="7" />
            <circle class="pt" cx="48" cy="72" r="3.5" />
          </g>
          <g class="p9">
            <circle class="ring" cx="70" cy="132" r="7" />
            <circle class="pt" cx="70" cy="132" r="3.5" />
          </g>
          <g class="p10">
            <circle class="ring" cx="86" cy="56" r="7" />
            <circle class="pt" cx="86" cy="56" r="3.5" />
          </g>
          <g class="p11">
            <circle class="ring" cx="118" cy="152" r="7" />
            <circle class="pt" cx="118" cy="152" r="3.5" />
          </g>
          <g class="p12">
            <circle class="ring" cx="214" cy="58" r="7" />
            <circle class="pt" cx="214" cy="58" r="3.5" />
          </g>
          <g class="p13">
            <circle class="ring" cx="238" cy="142" r="7" />
            <circle class="pt" cx="238" cy="142" r="3.5" />
          </g>
          <g class="p14">
            <circle class="ring" cx="258" cy="92" r="7" />
            <circle class="pt" cx="258" cy="92" r="3.5" />
          </g>
          <g class="p15">
            <circle class="ring" cx="268" cy="152" r="7" />
            <circle class="pt" cx="268" cy="152" r="3.5" />
          </g>
          <g class="p16">
            <circle class="ring" cx="236" cy="44" r="7" />
            <circle class="pt" cx="236" cy="44" r="3.5" />
          </g>
          <g class="p17">
            <circle class="ring" cx="36" cy="150" r="7" />
            <circle class="pt" cx="36" cy="150" r="3.5" />
          </g>
          <g class="p18">
            <circle class="ring" cx="190" cy="160" r="7" />
            <circle class="pt" cx="190" cy="160" r="3.5" />
          </g>
          <g class="p19">
            <circle class="ring" cx="62" cy="100" r="7" />
            <circle class="pt" cx="62" cy="100" r="3.5" />
          </g>
        </g>
        <polyline
          class="trail"
          pathLength="100"
          points="95.5,91.1 96.4,88.4 97.8,85.2 99.8,81.6 102.9,77.7 107.4,73.7 113.6,70.1 121.7,67.5 131.3,66.1 141.5,66.2 151.7,67.3 161.3,68.7 170.7,69.9 180.6,70.9 191,72.6 201.3,75.7 210.6,80.3 218.5,86.3 225.2,93.2 230.4,101.1 232.7,109.6 230.6,118.2 224,125.7 214.4,131.4 204.2,135.6 194.6,139.1 185.5,142.5 176.2,145.5 166.6,147.4 157,147.9 148,146.9 140.2,145 133.4,142.5 127.7,140 122.7,137.6 118.4,135.5 114.6,133.5 111.4,131.7"
        />
        <line class="chord" x1="111.4" y1="131.67" x2="95.46" y2="91.05" />
        <g class="pointer">
          <path d="M0 0 L0 13.5 L3.6 10.2 L6.2 15.6 L8.6 14.5 L6 9.2 L10.8 9.2 Z" />
        </g>
      </svg>
    </div>
  </body>
</html>