{
  "format": "oryvio-effect",
  "formatVersion": 1,
  "id": "dev.oryvio.stripes",
  "name": "Moving Stripes",
  "version": "1.0.0",
  "author": "Oryvio",
  "description": "Draws stripes of two colors over the picture, drifting as the clip plays.",
  "category": "Patterns",
  "kind": "generator",
  "params": [
    {
      "key": "colorA",
      "type": "color",
      "label": "First color",
      "default": "#1f2a44"
    },
    {
      "key": "colorB",
      "type": "color",
      "label": "Second color",
      "default": "#e8b04a"
    },
    {
      "key": "width",
      "type": "float",
      "label": "Width",
      "default": 60,
      "tip": "How wide each stripe is, in the picture’s pixels.",
      "min": 1,
      "max": 2000,
      "slider": [
        4,
        400
      ],
      "unit": "px"
    },
    {
      "key": "angle",
      "type": "angle",
      "label": "Angle",
      "default": 30,
      "min": -180,
      "max": 180
    },
    {
      "key": "drift",
      "type": "float",
      "label": "Drift",
      "default": 40,
      "tip": "How far they move a second, in pixels.",
      "min": -2000,
      "max": 2000,
      "slider": [
        -400,
        400
      ],
      "unit": "px"
    }
  ],
  "inputs": [
    "source"
  ],
  "wgsl": "// Moving Stripes: two colors in bands across the picture, drifting with time.\nfn render(uv: vec2f) -> vec4f {\n  let p = toPicture(uv);\n  let dir = vec2f(cos(params.angle), sin(params.angle));\n  let w = max(params.width, 1.0);\n  let phase = fract((dot(p, dir) - params.drift * frame.time) / (2.0 * w));\n  // A pixel of the picture is this much of a phase: each stripe's edges are antialiased over it.\n  let px = 0.5 / w;\n  let s = smoothstep(0.5 - px, 0.5 + px, phase) - smoothstep(1.0 - px, 1.0 + px, phase) + 1.0 - smoothstep(-px, px, phase);\n  let c = toStored(mix(toLinear(params.colorA.rgb), toLinear(params.colorB.rgb), clamp(s, 0.0, 1.0)));\n  return vec4f(c, 1.0);\n}\n"
}
