{
  "$schema": "../../schema.json",
  "id": "mask-reveal",
  "type": "transition",
  "title": "Mask reveal",
  "summary": "B is revealed from one edge, behind a hard mask line.",
  "tags": [
    "transition",
    "fast",
    "graphic"
  ],
  "version": "1.0.0",
  "license": "MIT",
  "export": "maskReveal",
  "signature": "maskReveal(a, b, p, { from, curve })",
  "params": [
    {
      "name": "from",
      "type": "enum",
      "default": "bottom",
      "description": "start value",
      "options": [
        "bottom",
        "top",
        "left",
        "right"
      ],
      "control": "segmented",
      "group": "main"
    },
    {
      "name": "curve",
      "type": "function",
      "default": "ease.outExpo",
      "description": "easing function (from `ease`)",
      "control": "ease",
      "group": "main"
    }
  ],
  "install": {
    "kind": "code"
  },
  "files": [
    {
      "path": "moves/mask-reveal.js",
      "content": "import { ease } from 'paper-motion';\nimport { E } from 'paper-motion/kit';\n\n/** B is revealed from an edge (`from`: bottom, top, left, right) behind a hard mask. */\nexport function maskReveal(a, b, p, { from = 'bottom', curve = ease.outExpo } = {}) {\n  const r = (1 - E(p, curve)) * 100;\n  const inset = { bottom: `${r}% 0 0 0`, top: `0 0 ${r}% 0`, left: `0 ${r}% 0 0`, right: `0 0 0 ${r}%` }[from];\n  b.style.clipPath = `inset(${inset})`; b.style.opacity = 1;\n  if (a) a.style.opacity = p >= 1 ? 0 : 1;\n}\n"
    }
  ],
  "requires": {
    "engine": ">=0.2.0"
  },
  "usage": "import { maskReveal } from './moves/mask-reveal.js';\n\n// two stacked layers, B above A; in s.update(t), from 2.0 s to 2.6 s:\nmaskReveal(a, b, progress(t, 2.0, 2.6));",
  "notes": [
    "B is revealed from an edge (`from`: bottom, top, left, right) behind a hard mask.",
    "At p = 0 only A shows, at p = 1 only B; keep B above A (z-index)."
  ],
  "preview": {
    "video": "previews/mask-reveal.webm",
    "poster": "previews/mask-reveal.jpg"
  },
  "mood": [
    "bold",
    "editorial",
    "minimal"
  ],
  "energy": 3,
  "role": "enter",
  "when": [
    "a hard graphic edge fits the brand",
    "revealing a title or a frame on the beat"
  ]
}