Back to the library

Stroke gesture — scratch out to delete

Variant: Scratch out

Deleting a stroke on a sketch canvas by scribbling over it, as pen-first apps do. Here an arrow is drawn from Draft straight to Ship, skipping Review, and is then scratched out. The scratch is drawn in the same graphite as everything else, because until the pen lifts it might be ink: a patch of shading, or a crossing-out the user means to keep. The decision waits for the lift, and the result shows 120ms after it: the scratch and everything it caught turn rust together in 96ms and hold there for 420ms while the caption says “Arrow deleted”, then leave together in 200ms on ease-out. That rust hold is the recogniser showing what it took. It took the arrowhead and the tail as well, which the scratch never crossed, because deletion here works on whole shapes, not on the pixels under the pen; an eraser takes pixels, and this is not one. The Draft → Review arrow, never crossed, does not react at all. The exit is opacity only, with no shrink and no drift, because a scratched-out stroke leaves no trace, and a stroke that moved on its way out would seem to be going somewhere. Under reduced motion the pen goes and each stroke fades in whole over the time it would have taken to draw; the catch and the exit keep their timing. Reach for it for whiteboards, annotation layers and any ink surface where switching tools is the slow part.

svgline-drawinggesturecontroldiagramloop

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 — scratch out</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 — 4.8s (1% = 48ms). A stray arrow drawn in 780ms, a 600ms
           scratch across it, a 120ms wait after the pen lifts, a catch held in
           rust for 420ms and a 200ms exit; the rest is the canvas as left. */
        --cycle: 4.8s;
        --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) 78%, 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;
      }

      .ink {
        fill: none;
        stroke: var(--_ink);
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
      }

      .label {
        font-size: 13px;
        font-weight: 500;
        fill: var(--_ink);
        text-anchor: middle;
      }

      /* Ink and scratch share one group, so they turn and leave on the same
         frames — the user sees the pair as one decision. */
      .doomed {
        stroke: var(--_ink);
        animation: doomed var(--t) infinite;
      }

      .doomed .ink {
        stroke: inherit;
      }

      .draw {
        stroke-dasharray: 100 200;
        stroke-dashoffset: 102;
      }

      .shaft {
        animation: shaft var(--t) infinite linear;
      }

      .head {
        animation: head var(--t) infinite linear;
      }

      /* The scratch is drawn in the same graphite as everything else. Until
         the pen lifts it might be ink — a shaded area, a crossed-out word the
         user wants kept — so it gets no special colour while it is being made. */
      .scribble {
        stroke-width: 1.8;
        animation: scribble var(--t) infinite linear;
      }

      .caption {
        display: grid;
        padding: 0 16px 14px;
        font-size: 12.5px;
        font-weight: 500;
        color: var(--_ink);
      }

      .caption span {
        grid-area: 1 / 1;
        opacity: 0;
      }

      .c-idle {
        animation: c-idle var(--t) infinite;
      }

      /* Named on the catch frame, in the same rust as the strokes it names. */
      .c-done {
        color: var(--rust);
        animation: c-done var(--t) infinite;
      }

      .pen {
        fill: var(--slate);
        opacity: 0;
        animation: pen var(--t) infinite linear;
      }

      @keyframes doomed {
        0% {
          opacity: 1;
          stroke: var(--_ink);
        }
        50.42% {
          opacity: 1;
          stroke: var(--_ink);
          animation-timing-function: ease;
        }
        52.42% {
          opacity: 1;
          stroke: var(--rust);
        }
        59.17% {
          opacity: 1;
          stroke: var(--rust);
          animation-timing-function: var(--ease-out);
        }
        63.33% {
          opacity: 0;
          stroke: var(--rust);
        }
        67.54% {
          opacity: 0;
          stroke: var(--rust);
          animation-timing-function: linear;
        }
        67.56% {
          opacity: 1;
          stroke: var(--_ink);
        }
        100% {
          opacity: 1;
          stroke: var(--_ink);
        }
      }

      @keyframes shaft {
        0% {
          stroke-dashoffset: 102;
        }
        7.5% {
          stroke-dashoffset: 102;
        }
        8.33% {
          stroke-dashoffset: 97.24;
        }
        9.17% {
          stroke-dashoffset: 92.97;
        }
        10% {
          stroke-dashoffset: 87.32;
        }
        10.83% {
          stroke-dashoffset: 80.42;
        }
        11.67% {
          stroke-dashoffset: 72.5;
        }
        12.5% {
          stroke-dashoffset: 63.82;
        }
        13.33% {
          stroke-dashoffset: 54.66;
        }
        14.17% {
          stroke-dashoffset: 45.34;
        }
        15% {
          stroke-dashoffset: 36.18;
        }
        15.83% {
          stroke-dashoffset: 27.5;
        }
        16.67% {
          stroke-dashoffset: 19.58;
        }
        17.5% {
          stroke-dashoffset: 12.68;
        }
        18.33% {
          stroke-dashoffset: 7.03;
        }
        19.17% {
          stroke-dashoffset: 2.76;
        }
        20% {
          stroke-dashoffset: 0;
        }
        67.5% {
          stroke-dashoffset: 0;
        }
        67.52% {
          stroke-dashoffset: 102;
        }
        100% {
          stroke-dashoffset: 102;
        }
      }

      @keyframes head {
        0% {
          stroke-dashoffset: 102;
        }
        22.5% {
          stroke-dashoffset: 102;
        }
        23.13% {
          stroke-dashoffset: 83.33;
        }
        23.75% {
          stroke-dashoffset: 66.67;
        }
        24.38% {
          stroke-dashoffset: 50;
        }
        25% {
          stroke-dashoffset: 33.33;
        }
        25.62% {
          stroke-dashoffset: 16.67;
        }
        26.25% {
          stroke-dashoffset: 0;
        }
        67.5% {
          stroke-dashoffset: 0;
        }
        67.52% {
          stroke-dashoffset: 102;
        }
        100% {
          stroke-dashoffset: 102;
        }
      }

      @keyframes scribble {
        0% {
          stroke-dashoffset: 102;
        }
        35.42% {
          stroke-dashoffset: 102;
          animation-timing-function: linear;
        }
        35.73% {
          stroke-dashoffset: 96.56;
          animation-timing-function: linear;
        }
        36.04% {
          stroke-dashoffset: 95.26;
          animation-timing-function: linear;
        }
        36.35% {
          stroke-dashoffset: 93.05;
          animation-timing-function: linear;
        }
        36.67% {
          stroke-dashoffset: 89.3;
          animation-timing-function: linear;
        }
        36.98% {
          stroke-dashoffset: 86.52;
          animation-timing-function: linear;
        }
        37.29% {
          stroke-dashoffset: 85.96;
          animation-timing-function: linear;
        }
        37.6% {
          stroke-dashoffset: 82.99;
          animation-timing-function: linear;
        }
        37.92% {
          stroke-dashoffset: 79.29;
          animation-timing-function: linear;
        }
        38.23% {
          stroke-dashoffset: 77.33;
          animation-timing-function: linear;
        }
        38.54% {
          stroke-dashoffset: 75.83;
          animation-timing-function: linear;
        }
        38.85% {
          stroke-dashoffset: 72.28;
          animation-timing-function: linear;
        }
        39.17% {
          stroke-dashoffset: 68.99;
          animation-timing-function: linear;
        }
        39.48% {
          stroke-dashoffset: 68.06;
          animation-timing-function: linear;
        }
        39.79% {
          stroke-dashoffset: 65.69;
          animation-timing-function: linear;
        }
        40.1% {
          stroke-dashoffset: 61.92;
          animation-timing-function: linear;
        }
        40.42% {
          stroke-dashoffset: 59.31;
          animation-timing-function: linear;
        }
        40.73% {
          stroke-dashoffset: 58.44;
          animation-timing-function: linear;
        }
        41.04% {
          stroke-dashoffset: 55.28;
          animation-timing-function: linear;
        }
        41.35% {
          stroke-dashoffset: 51.65;
          animation-timing-function: linear;
        }
        41.67% {
          stroke-dashoffset: 49.98;
          animation-timing-function: linear;
        }
        41.98% {
          stroke-dashoffset: 48.31;
          animation-timing-function: linear;
        }
        42.29% {
          stroke-dashoffset: 44.68;
          animation-timing-function: linear;
        }
        42.6% {
          stroke-dashoffset: 41.52;
          animation-timing-function: linear;
        }
        42.92% {
          stroke-dashoffset: 40.69;
          animation-timing-function: linear;
        }
        43.23% {
          stroke-dashoffset: 38.07;
          animation-timing-function: linear;
        }
        43.54% {
          stroke-dashoffset: 34.31;
          animation-timing-function: linear;
        }
        43.85% {
          stroke-dashoffset: 31.92;
          animation-timing-function: linear;
        }
        44.17% {
          stroke-dashoffset: 30.96;
          animation-timing-function: linear;
        }
        44.48% {
          stroke-dashoffset: 27.66;
          animation-timing-function: linear;
        }
        44.79% {
          stroke-dashoffset: 24.12;
          animation-timing-function: linear;
        }
        45.1% {
          stroke-dashoffset: 22.65;
          animation-timing-function: linear;
        }
        45.42% {
          stroke-dashoffset: 20.71;
          animation-timing-function: linear;
        }
        45.73% {
          stroke-dashoffset: 17.01;
          animation-timing-function: linear;
        }
        46.04% {
          stroke-dashoffset: 14.03;
          animation-timing-function: linear;
        }
        46.35% {
          stroke-dashoffset: 13.37;
          animation-timing-function: linear;
        }
        46.67% {
          stroke-dashoffset: 10.57;
          animation-timing-function: linear;
        }
        46.98% {
          stroke-dashoffset: 6.83;
          animation-timing-function: linear;
        }
        47.29% {
          stroke-dashoffset: 4.66;
          animation-timing-function: linear;
        }
        47.6% {
          stroke-dashoffset: 3.43;
          animation-timing-function: linear;
        }
        47.92% {
          stroke-dashoffset: 0;
          animation-timing-function: linear;
        }
        67.5% {
          stroke-dashoffset: 0;
        }
        67.52% {
          stroke-dashoffset: 102;
        }
        100% {
          stroke-dashoffset: 102;
        }
      }

      @keyframes pen {
        0% {
          opacity: 0;
          transform: translate(64px, 70px);
        }
        4.17% {
          opacity: 0;
          transform: translate(64px, 70px);
          animation-timing-function: var(--ease-out);
        }
        6.67% {
          opacity: 1;
          transform: translate(64px, 70px);
        }
        7.5% {
          opacity: 1;
          transform: translate(64px, 70px);
        }
        8.33% {
          opacity: 1;
          transform: translate(63.8px, 74.2px);
        }
        9.17% {
          opacity: 1;
          transform: translate(64.1px, 80.6px);
        }
        10% {
          opacity: 1;
          transform: translate(65.8px, 89px);
        }
        10.83% {
          opacity: 1;
          transform: translate(70.2px, 98.4px);
        }
        11.67% {
          opacity: 1;
          transform: translate(78.1px, 107.4px);
        }
        12.5% {
          opacity: 1;
          transform: translate(89.1px, 114.6px);
        }
        13.33% {
          opacity: 1;
          transform: translate(101.9px, 119.9px);
        }
        14.17% {
          opacity: 1;
          transform: translate(115.6px, 123.4px);
        }
        15% {
          opacity: 1;
          transform: translate(129.3px, 125.6px);
        }
        15.83% {
          opacity: 1;
          transform: translate(142.4px, 127px);
        }
        16.67% {
          opacity: 1;
          transform: translate(154.3px, 127.7px);
        }
        17.5% {
          opacity: 1;
          transform: translate(164.8px, 128px);
        }
        18.33% {
          opacity: 1;
          transform: translate(173.4px, 128.1px);
        }
        19.17% {
          opacity: 1;
          transform: translate(179.8px, 128px);
        }
        20% {
          opacity: 1;
          transform: translate(184px, 128px);
          animation-timing-function: var(--ease-out);
        }
        22.5% {
          opacity: 1;
          transform: translate(176px, 122px);
        }
        23.13% {
          opacity: 1;
          transform: translate(178.8px, 124px);
        }
        23.75% {
          opacity: 1;
          transform: translate(181.6px, 125.9px);
        }
        24.38% {
          opacity: 1;
          transform: translate(184.4px, 127.9px);
        }
        25% {
          opacity: 1;
          transform: translate(181.9px, 130px);
        }
        25.62% {
          opacity: 1;
          transform: translate(179.2px, 132.1px);
        }
        26.25% {
          opacity: 1;
          transform: translate(176.5px, 134.2px);
          animation-timing-function: var(--ease-in-out);
        }
        35.42% {
          opacity: 1;
          transform: translate(76.5px, 105.9px);
        }
        35.73% {
          opacity: 1;
          transform: translate(71.8px, 114px);
        }
        36.04% {
          opacity: 1;
          transform: translate(71.7px, 117.5px);
        }
        36.35% {
          opacity: 1;
          transform: translate(76.9px, 114.4px);
        }
        36.67% {
          opacity: 1;
          transform: translate(84.2px, 107.4px);
        }
        36.98% {
          opacity: 1;
          transform: translate(89.6px, 102.2px);
        }
        37.29% {
          opacity: 1;
          transform: translate(90.7px, 103.3px);
        }
        37.6% {
          opacity: 1;
          transform: translate(88.1px, 110.9px);
        }
        37.92% {
          opacity: 1;
          transform: translate(85px, 120.5px);
        }
        38.23% {
          opacity: 1;
          transform: translate(84.6px, 125.8px);
        }
        38.54% {
          opacity: 1;
          transform: translate(88px, 123.5px);
        }
        38.85% {
          opacity: 1;
          transform: translate(93.6px, 115.7px);
        }
        39.17% {
          opacity: 1;
          transform: translate(98.6px, 108.3px);
        }
        39.48% {
          opacity: 1;
          transform: translate(100.8px, 107.1px);
        }
        39.79% {
          opacity: 1;
          transform: translate(100.2px, 113.5px);
        }
        40.1% {
          opacity: 1;
          transform: translate(98.5px, 123.6px);
        }
        40.42% {
          opacity: 1;
          transform: translate(98.2px, 130.6px);
        }
        40.73% {
          opacity: 1;
          transform: translate(100.5px, 130.1px);
        }
        41.04% {
          opacity: 1;
          transform: translate(104.7px, 122.6px);
        }
        41.35% {
          opacity: 1;
          transform: translate(109px, 113.8px);
        }
        41.67% {
          opacity: 1;
          transform: translate(111.7px, 110.2px);
        }
        41.98% {
          opacity: 1;
          transform: translate(112.3px, 114.7px);
        }
        42.29% {
          opacity: 1;
          transform: translate(111.8px, 124.5px);
        }
        42.6% {
          opacity: 1;
          transform: translate(111.9px, 133px);
        }
        42.92% {
          opacity: 1;
          transform: translate(113.5px, 134.6px);
        }
        43.23% {
          opacity: 1;
          transform: translate(116.7px, 128.3px);
        }
        43.54% {
          opacity: 1;
          transform: translate(120.3px, 118.7px);
        }
        43.85% {
          opacity: 1;
          transform: translate(123.1px, 112.9px);
        }
        44.17% {
          opacity: 1;
          transform: translate(124.5px, 115.1px);
        }
        44.48% {
          opacity: 1;
          transform: translate(124.9px, 124.1px);
        }
        44.79% {
          opacity: 1;
          transform: translate(125.4px, 133.7px);
        }
        45.1% {
          opacity: 1;
          transform: translate(126.8px, 137.4px);
        }
        45.42% {
          opacity: 1;
          transform: translate(129.3px, 132.7px);
        }
        45.73% {
          opacity: 1;
          transform: translate(132.3px, 123.2px);
        }
        46.04% {
          opacity: 1;
          transform: translate(134.9px, 115.5px);
        }
        46.35% {
          opacity: 1;
          transform: translate(136.7px, 115.3px);
        }
        46.67% {
          opacity: 1;
          transform: translate(137.7px, 122.8px);
        }
        46.98% {
          opacity: 1;
          transform: translate(138.6px, 132.9px);
        }
        47.29% {
          opacity: 1;
          transform: translate(140px, 138.7px);
        }
        47.6% {
          opacity: 1;
          transform: translate(142.1px, 136.1px);
        }
        47.92% {
          opacity: 1;
          transform: translate(144.6px, 127.1px);
          animation-timing-function: var(--ease-out);
        }
        50.83% {
          opacity: 0;
          transform: translate(150.6px, 119.1px);
        }
        100% {
          opacity: 0;
          transform: translate(150.6px, 119.1px);
        }
      }

      @keyframes c-idle {
        0% {
          opacity: 1;
        }
        50.42% {
          opacity: 1;
          animation-timing-function: ease;
        }
        52.29% {
          opacity: 0;
        }
        94.38% {
          opacity: 0;
          animation-timing-function: ease;
        }
        97.29% {
          opacity: 1;
        }
        100% {
          opacity: 1;
        }
      }

      @keyframes c-done {
        0% {
          opacity: 0;
        }
        52.29% {
          opacity: 0;
          animation-timing-function: ease;
        }
        55.21% {
          opacity: 1;
        }
        92.5% {
          opacity: 1;
          animation-timing-function: ease;
        }
        94.38% {
          opacity: 0;
        }
        100% {
          opacity: 0;
        }
      }

      @media (prefers-reduced-motion: reduce) {
        /* Same score, 1.6x slower. No pen and no drawing travel: each stroke
           fades in whole over the time it would have taken to draw, and the
           catch and the exit land exactly as before. */
        :root {
          --t: calc(var(--cycle) * 1.6 / var(--speed));
        }

        .pen {
          display: none;
        }

        .draw {
          stroke-dashoffset: 0;
          stroke-dasharray: none;
        }

        .shaft {
          animation: shaft-calm var(--t) infinite;
        }

        .head {
          animation: head-calm var(--t) infinite;
        }

        .scribble {
          animation: scribble-calm var(--t) infinite;
        }

        @keyframes shaft-calm {
          0% {
            opacity: 0;
          }
          7.5% {
            opacity: 0;
            animation-timing-function: ease;
          }
          20% {
            opacity: 1;
          }
          67.5% {
            opacity: 1;
            animation-timing-function: linear;
          }
          67.52% {
            opacity: 0;
          }
          100% {
            opacity: 0;
          }
        }

        @keyframes head-calm {
          0% {
            opacity: 0;
          }
          22.5% {
            opacity: 0;
            animation-timing-function: ease;
          }
          26.25% {
            opacity: 1;
          }
          67.5% {
            opacity: 1;
            animation-timing-function: linear;
          }
          67.52% {
            opacity: 0;
          }
          100% {
            opacity: 0;
          }
        }

        @keyframes scribble-calm {
          0% {
            opacity: 0;
          }
          35.42% {
            opacity: 0;
            animation-timing-function: ease;
          }
          47.92% {
            opacity: 1;
          }
          67.5% {
            opacity: 1;
            animation-timing-function: linear;
          }
          67.52% {
            opacity: 0;
          }
          100% {
            opacity: 0;
          }
        }
      }
    </style>
  </head>
  <body>
    <div class="card">
      <svg
        viewBox="0 0 300 166"
        role="img"
        aria-label="On a sketch canvas, a pen draws an arrow from a box labelled Draft straight to Ship, skipping Review, then scratches back and forth across it. When the pen lifts, the scratch and the whole arrow, head and tail included, turn rust together, the caption reads Arrow deleted, and they disappear, leaving the Draft to Review arrow untouched"
      >
        <path
          class="ink"
          d="M 31 24.6 L 99 23.4 Q 108 24 108.8 33 L 107.2 55 Q 108 64 99 63.5 L 31 64.5 Q 22 64 22.7 55 L 21.3 33 Q 22 24 31 24.6"
        />
        <text class="label" x="65" y="48.5">Draft</text>
        <path
          class="ink"
          d="M 201 23.5 L 269 24.5 Q 278 24 278.6 33 L 277.4 55 Q 278 64 269 64.7 L 201 63.3 Q 192 64 191.4 55 L 192.6 33 Q 192 24 201 23.5"
        />
        <text class="label" x="235" y="48.5">Review</text>
        <path
          class="ink"
          d="M 201 108.4 L 269 107.6 Q 278 108 277.3 117 L 278.7 139 Q 278 148 269 148.5 L 201 147.5 Q 192 148 192.6 139 L 191.4 117 Q 192 108 201 108.4"
        />
        <text class="label" x="235" y="132.5">Ship</text>
        <path class="ink" d="M 116 45 C 140 41, 160 42, 182 44.5" />
        <path class="ink" d="M 175 39 L 183.5 44.6 L 175.5 50.5" />
        <g class="doomed">
          <path class="ink draw shaft" pathLength="100" d="M 64 70 C 60 120, 116 129, 184 128" />
          <polyline class="ink draw head" pathLength="100" points="176,122 184.5,128 176.5,134.2" />
          <polyline
            class="ink draw scribble"
            pathLength="100"
            points="76.5,105.9 71.8,114 71.7,117.5 76.9,114.4 84.2,107.4 89.6,102.2 90.7,103.3 88.1,110.9 85,120.5 84.6,125.8 88,123.5 93.6,115.7 98.6,108.3 100.8,107.1 100.2,113.5 98.5,123.6 98.2,130.6 100.5,130.1 104.7,122.6 109,113.8 111.7,110.2 112.3,114.7 111.8,124.5 111.9,133 113.5,134.6 116.7,128.3 120.3,118.7 123.1,112.9 124.5,115.1 124.9,124.1 125.4,133.7 126.8,137.4 129.3,132.7 132.3,123.2 134.9,115.5 136.7,115.3 137.7,122.8 138.6,132.9 140,138.7 142.1,136.1 144.6,127.1"
          />
        </g>
        <circle class="pen" cx="0" cy="0" r="3.6" />
      </svg>
      <div class="caption">
        <span class="c-idle">Scratch over a stroke to delete it</span>
        <span class="c-done">Arrow deleted</span>
      </div>
    </div>
  </body>
</html>