# Papel cebolla

La golondrina seleccionada se mantiene opaca mientras los dibujos adyacentes se superponen con transparencia. Así se aprecia cuánto avanza el ave y dónde gira la punta del ala.

## Cómo probarlo

Con el dibujo 4 seleccionado, desactiva «Dibujo siguiente» y compara las alas de los dibujos 3 y 4. Actívalo de nuevo para ver la posición del ala en el dibujo 5.

## Detalles de la interacción

Se elige uno de siete dibujos. El anterior lleva un contorno rojo a rayas y el siguiente, uno azul de puntos. En los extremos solo se muestran los vecinos que existen. Las dos opciones se conservan al cambiar de dibujo.

## Controles por plataforma

- iOS · Toca el número de un dibujo. Toca «Dibujo anterior» y «Dibujo siguiente» por separado para comparar las alas.
- Android · Toca el número de un dibujo para cambiar de pose. Pulsa «Dibujo anterior» o «Dibujo siguiente» para elegir qué dibujos superponer.
- PC · Haz clic en un número o usa Tab para enfocar el dibujo seleccionado y las flechas para cambiarlo. Pulsa Espacio o Intro en un control para mostrar u ocultar el dibujo vecino.

## Dónde usarlo

Sirve para revisar la separación entre poses dibujadas a mano y decidir si hace falta un dibujo intermedio.

## Instrucciones de implementación

> Mantén opaco el dibujo seleccionado. Permite mostrar u ocultar por separado los dibujos anterior y siguiente en el mismo lienzo, con colores y trazos distintos.

## Fuentes y créditos

[Krita · Onion Skin Docker](<https://docs.krita.org/en/reference_manual/dockers/onion_skin.html>)

## Ejemplo en HTML

Guarda el siguiente código en un archivo HTML y ábrelo en tu navegador. Puedes usar el ejemplo sin conexión.

```html
<!doctype html>
<html lang="es" data-motion-locales="inline">
<head><script>if(new URLSearchParams(location.search).get('reduce')==='1')document.documentElement.classList.add('motion-reduced');</script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>어니언 스킨 · MotionLab</title>
<style>
  * { box-sizing: border-box; }
  :root {
    color-scheme: light;
    font: 15px/1.45 "Segoe UI", system-ui, sans-serif;
    color: #25352f;
    background: #edeade;
  }
  body { margin: 0; min-height: 100svh; display: grid; align-content: center; padding: clamp(10px, 3vw, 30px); }
  main { width: min(100%, 800px); min-width: 0; margin-inline: auto; }
  header { margin-bottom: 12px; display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 5px 18px; }
  h1 { margin: 0; font-size: clamp(21px, 4.8vw, 38px); line-height: 1.15; letter-spacing: -.05em; }
  .technique, .count { font: 650 12px/1.3 ui-monospace, monospace; }
  .board { overflow: hidden; border: 1px solid #a5a898; border-radius: 8px; background: #fffbea; }
  .canvas { display: block; width: 100%; height: auto; }
  .controls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px clamp(7px, 2vw, 15px); border-top: 1px solid #c8c9b9; background: #f9f6e9; }
  button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 42px; padding: 5px 10px; border: 1px solid #96998c; border-radius: 5px; background: #fffdf4; color: #333c35; font-family: inherit; font-size: 13px; font-weight: 650; line-height: 1.25; cursor: pointer; touch-action: manipulation; }
  button[aria-pressed=true] { background: #e9eee3; border-color: #626e61; }
  .swatch { flex: none; width: 21px; height: 0; border-top: 3px dashed #a1443a; }
  #toggle-next .swatch { border-top: 3px dotted #316880; }
  button[aria-pressed=false] .swatch { opacity: .38; }
  button[aria-pressed=false] { color: #5e625b; }
  button:focus-visible, input:focus-visible + span { outline: 3px solid #304fd0; outline-offset: 2px; }
  .count { margin-inline-start: auto; white-space: nowrap; }
  fieldset { min-width: 0; padding: 0; margin: 12px 0 0; border: 0; }
  legend { margin: 0 0 5px; padding: 0; font-weight: 650; font-size: 12px; }
  #frames { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); gap: 5px; }
  .frame { position: relative; min-width: 0; cursor: pointer; touch-action: manipulation; }
  .frame span { display: grid; min-height: 45px; border: 1px solid #a4a898; border-radius: 4px; justify-items: center; padding: 2px 2px 3px; background: #f9f6e9; font: 650 11px/1.2 ui-monospace, monospace; }
  .frame input:checked + span { color: #fffcec; background: #293d36; border-color: #293d36; }
  .frame svg { width: 100%; max-width: 68px; height: 27px; fill: currentColor; }
  .visually-hidden, .frame input { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
  p { margin: 8px 0 0; color: #425247; font-size: 13px; }
  .pose { stroke-linecap: round; stroke-linejoin: round; }
  .current { --back: #728e78; --wing: #34564f; --body: #263d3b; --detail: #e1bc7a; stroke: #243c39; stroke-width: 1.5; }
  .previous { --back: #dfb6a2; --wing: #e3b19e; --body: #dfad9d; --detail: #a95042; stroke: #ad5949; stroke-dasharray: 4 3; stroke-width: 2; opacity: .73; }
  .next { --back: #b0c8c7; --wing: #a9c8ce; --body: #a9c5cf; --detail: #4a788b; stroke: #4b7a8b; stroke-dasharray: 1 3; stroke-width: 2; opacity: .75; }
  @media(max-width: 420px) {
    body { padding: 9px; }
    header { margin-bottom: 7px; }
    .controls { gap: 5px; }
    button { min-height: 44px; padding: 4px 7px; }
    .count { font-size: 11px; }
    #frames { gap: 3px; }
    .frame span { min-height: 44px; }
  }
</style>
</head>
<body>
<main>
  <header><h1 id="heading"></h1><span class="technique" id="technique"></span></header>
  <section class="board" aria-labelledby="heading">
    <svg class="canvas" viewBox="0 0 640 238" role="img" aria-labelledby="drawing-title">
      <title id="drawing-title"></title>
      <defs>
        <pattern id="grid" width="20" height="20" patternUnits="userSpaceOnUse"><circle cx="10" cy="10" r=".8" fill="#d5d3ba"/></pattern>
      </defs>
      <rect width="640" height="238" fill="#fcf8e8"/>
      <rect x="19" y="19" width="602" height="200" fill="url(#grid)"/>
      <path d="M16 30V16h14m580 0h14v14M16 208v14h14m580 0h14v-14" fill="none" stroke="#929a86" stroke-width="1.2"/>
      <g id="ghost-previous" class="pose previous"></g>
      <g id="ghost-next" class="pose next"></g>
      <g id="active-pose" class="pose current"></g>
    </svg>
    <div class="controls">
      <button id="toggle-previous" type="button" aria-pressed="true" aria-controls="ghost-previous"><i aria-hidden="true" class="swatch"></i><span></span></button>
      <button id="toggle-next" type="button" aria-pressed="true" aria-controls="ghost-next"><i aria-hidden="true" class="swatch"></i><span></span></button>
      <output class="count" id="counter" aria-live="off"></output>
    </div>
  </section>
  <fieldset><legend id="frames-label"></legend><div id="frames"></div></fieldset>
  <p id="instruction"></p>
  <output id="announcement" class="visually-hidden" aria-live="polite" aria-atomic="true"></output>
</main>
<script>
(() => {
  const copy = {
    ko: {
      heading: '제비의 날갯짓', technique: '어니언 스킨', previous: '이전 그림', next: '다음 그림',
      frames: '원화 선택', frame: n => n+'번 그림', current: '현재 그림', none: '현재 그림만 표시',
      help: '원화를 고른 뒤 이전 그림과 다음 그림을 번갈아 켜 보세요. 진한 제비가 현재 그림입니다.',
      first: '첫 그림에는 이전 그림이 없습니다.', last: '마지막 그림에는 다음 그림이 없습니다.'
    },
    en: {
      heading: 'Swallow in flight', technique: 'Onion skinning', previous: 'Previous drawing', next: 'Next drawing',
      frames: 'Choose a drawing', frame: n => 'Drawing '+n, current: 'Current drawing', none: 'Only the current drawing is visible',
      help: 'Pick a drawing, then switch its neighbours on and off. The dark swallow is the current drawing.',
      first: 'The first drawing has no previous drawing.', last: 'The last drawing has no next drawing.'
    },
    es: {
      heading: 'El vuelo de la golondrina', technique: 'Papel cebolla', previous: 'Dibujo anterior', next: 'Dibujo siguiente',
      frames: 'Elige un dibujo', frame: n => 'Dibujo '+n, current: 'Dibujo actual', none: 'Solo se ve el dibujo actual',
      help: 'Elige un dibujo y activa o desactiva los dibujos vecinos. La golondrina oscura es el dibujo actual.',
      first: 'El primer dibujo no tiene dibujo anterior.', last: 'El último dibujo no tiene dibujo siguiente.'
    },
    'zh-Hans': {
      heading: '飞燕振翅', technique: '洋葱皮', previous: '上一张', next: '下一张',
      frames: '选择原画', frame: n => '第 '+n+' 张', current: '当前原画', none: '仅显示当前原画',
      help: '选一张原画，再分别显示或隐藏前后两张。深色的燕子是当前原画。',
      first: '这是第一张，没有上一张。', last: '这是最后一张，没有下一张。'
    }
  };
  const requested = new URLSearchParams(location.search).get('lang') || document.documentElement.lang || 'ko';
  const lang = /^zh/i.test(requested) ? 'zh-Hans' : requested.toLowerCase().split('-')[0];
  const words = copy[lang] || copy.ko;
  document.documentElement.lang = copy[lang] ? lang : 'ko';
  document.title = words.technique+' · MotionLab';
  const byId = id => document.getElementById(id);
  byId('heading').textContent = words.heading;
  byId('technique').textContent = words.technique;
  byId('frames-label').textContent = words.frames;
  byId('toggle-previous').lastElementChild.textContent = words.previous;
  byId('toggle-next').lastElementChild.textContent = words.next;

  // Each key drawing has its own wing tip, trailing edge and silhouette.
  const poses = [
    {x:97, y:148, angle:-10, tip:[-36,-72], elbow:[-3,-48], cuff:[-16,-34]},
    {x:164,y:134, angle:-9,  tip:[-49,-58], elbow:[-13,-40],cuff:[-21,-27]},
    {x:240,y:124, angle:-7,  tip:[-60,-24], elbow:[-24,-22],cuff:[-26,-17]},
    {x:320,y:116, angle:-5,  tip:[-54,35],  elbow:[-20,16], cuff:[-24,13]},
    {x:400,y:113, angle:-2,  tip:[-30,64],  elbow:[-8,38],  cuff:[-13,27]},
    {x:477,y:115, angle:1,   tip:[-52,38],  elbow:[-12,24], cuff:[-24,18]},
    {x:551,y:119, angle:3,   tip:[-53,-37], elbow:[-17,-25],cuff:[-21,-18]}
  ];
  let frame = 3;
  const enabled = {previous: true, next: true};
  const ns = 'http://www.w3.org/2000/svg';
  function svgNode(tag, attrs) {
    const node = document.createElementNS(ns, tag);
    for (const [name,value] of Object.entries(attrs)) node.setAttribute(name, value);
    return node;
  }
  function wing(pose, far) {
    const [x,y] = pose.tip, [ex,ey] = pose.elbow, [cx,cy] = pose.cuff;
    if (far) return 'M5 -6 Q'+(ex+19)+' '+(ey*.66)+' '+(x+23)+' '+(y*.76)+' Q'+(cx+12)+' '+(cy*.58)+' -10 3Z';
    return 'M2 -7 Q'+ex+' '+ey+' '+x+' '+y+' Q'+cx+' '+cy+' -17 4Z';
  }
  const body = 'M-52 8 L-30 -2 L-47 -6 L-18 -3 Q-4 -13 12 -10 Q20 -18 28 -12 L32 -8 L43 -6 L30 -3 Q22 6 6 7 Q-7 8 -20 2Z';
  function draw(layer, index) {
    layer.replaceChildren();
    if (index < 0 || index >= poses.length) return;
    const p = poses[index];
    layer.setAttribute('transform','translate('+p.x+' '+p.y+') rotate('+p.angle+') scale(1.30)');
    layer.append(
      svgNode('path', {d:wing(p,true),fill:'var(--back)'}),
      svgNode('path', {d:body,fill:'var(--body)'}),
      svgNode('path', {d:wing(p,false),fill:'var(--wing)'}),
      svgNode('path', {d:'M22 -8 Q25 -6 30 -7 Q27 -2 23 -1 Q21 -4 22 -8Z', fill:'var(--detail)',stroke:'none'}),
      svgNode('circle', {cx:26,cy:-10,r:1.3,fill:'#fff4cb',stroke:'none'})
    );
  }
  poses.forEach((p,index) => {
    const label = document.createElement('label');
    label.className = 'frame';
    const input = document.createElement('input');
    input.type = 'radio'; input.name = 'drawing'; input.value = String(index+1);
    input.setAttribute('aria-label', words.frame(index+1)); input.checked = index === frame;
    const face = document.createElement('span');
    face.setAttribute('aria-hidden','true');
    const thumb = svgNode('svg', {preserveAspectRatio:'xMidYMid meet'});
    // Centre each silhouette vertically in the thumbnail, preserving pose differences.
    const min = Math.min(-18,p.tip[1]), max = Math.max(10,p.tip[1]);
    thumb.setAttribute('viewBox','-65 '+(min-4)+' 112 '+(max-min+8));
    thumb.append(svgNode('path',{d:body}),svgNode('path',{d:wing(p,false)}));
    face.append(thumb, String(index+1).padStart(2,'0'));
    input.addEventListener('change', () => { if (input.checked) { frame=index; render(); } });
    label.append(input,face);
    byId('frames').append(label);
  });
  function render() {
    draw(byId('active-pose'),frame);
    draw(byId('ghost-previous'),enabled.previous ? frame-1 : -1);
    draw(byId('ghost-next'),enabled.next ? frame+1 : -1);
    byId('counter').textContent = String(frame+1).padStart(2,'0')+' / 07';
    const visible = [];
    if (enabled.previous && frame>0) visible.push(words.previous+' '+String(frame));
    if (enabled.next && frame<poses.length-1) visible.push(words.next+' '+String(frame+2));
    const status = words.current+' '+String(frame+1)+' · '+(visible.join(' · ') || words.none);
    byId('drawing-title').textContent = words.heading+' · '+status;
    byId('announcement').textContent = status;
    const edge = frame===0 ? words.first : frame===poses.length-1 ? words.last : '';
    byId('instruction').textContent = [words.help,edge].filter(Boolean).join(' ');
  }
  for (const key of ['previous','next']) {
    const toggle = byId('toggle-'+key);
    toggle.addEventListener('click', () => {
      enabled[key] = !enabled[key];
      toggle.setAttribute('aria-pressed', String(enabled[key]));
      render();
    });
  }
  render();
})();
</script>
</body>
</html>
```
