Übergang: Durchbrennen

Das alte Bild brennt in Inseln weg, dunkle Stellen zuerst, mit angekohltem Saum und glühendem Rand. `Engine.createNoise` liefert eine Reihenfolge, die in jedem Bild gleich bleibt, und `smoothstep` macht aus einer wandernden Schwelle alle drei Masken. Ein anderer `SEED` gibt andere Inseln.

A
A — Übergang: Durchbrennen
B
B — Übergang: Durchbrennen
Animation
Animation — Übergang: Durchbrennen
JavaScript
// Burn through — one transition between two photos, exported as a looping animated WebP.
//
// Everything specific sits in transition(from, to, T): it takes two images it may change and a
// progress T from 0 to 1, and returns one new frame. Video tools can call exactly that for each
// frame of a cut; the rest of this script only builds the animation.

//!INPUT: A, B
//!OUTPUT: OUT
//!PARAM: STEPS:integer=18,min=2,max=120
//!PARAM: DELAY_MS:integer=50,min=10,max=2000
//!PARAM: HOLD_MS:integer=700,min=0,max=5000
//!PARAM: COLOR:color=#ff6a13
//!PARAM: CORE:color=#ffe2a0
//!PARAM: SCALE:number=180,min=20,max=1200,step=10
//!PARAM: OCTAVES:integer=4,min=1,max=8
//!PARAM: DARK_FIRST:number=0.25,min=0,max=0.8,step=0.05
//!PARAM: EDGE:number=0.006,min=0.001,max=0.05,step=0.001
//!PARAM: CHAR:number=0.03,min=0.005,max=0.2,step=0.005
//!PARAM: SEED:integer=7,min=0,max=99999

function transition(from, to, T) {
  if (T <= 0 || T >= 1) {
    (T <= 0 ? to : from).free();
    return T <= 0 ? from : to;
  }
  const w = to.width, h = to.height;
  // Burn order: clouds, plus the dark areas of the old image.
  const field = Engine.createNoise(w, h, { scale: SCALE, octaves: OCTAVES, seed: SEED });
  const dark = from.clone().grayscale().invert();
  field.blend(dark, DARK_FIRST);
  dark.free();

  const s = -CHAR + T * (1 + 2 * CHAR);           // the threshold runs through the whole field
  const glow = Math.min(1, Math.min(T, 1 - T) * 12);  // the rim fades out at both ends

  // A band around the threshold: 0 far away, 1 on the edge.
  const band = (inner, outer) => {
    const a = field.clone().smoothstep(s - inner, s);
    const b = field.clone().smoothstep(s, s + outer).invert();
    a.blend(b, 1, Blend.Multiply);
    b.free();
    return a;
  };
  const lay = (color, mask, strength) => {
    const layer = Engine.createColoredImage(w, h, color).applyMask(mask);
    from.blendAt(layer, px(0, 0), strength, Blend.Over);
    layer.free();
    mask.free();
  };

  // Charred: a rim on the old image, ahead of the burning edge.
  lay("#1a0a00", field.clone().smoothstep(s, s + CHAR).invert(), 0.85 * glow);

  // Burnt through: the new image shows there.
  const open = field.clone().smoothstep(s - EDGE, s + EDGE).invert();
  to.applyMask(open);
  from.blendAt(to, px(0, 0), 1, Blend.Over);
  open.free();

  // Embers: a narrow rim in the colour, with a bright core inside.
  lay(COLOR, band(EDGE * 2, EDGE * 2.5), glow);
  lay(CORE, band(EDGE * 0.8, EDGE), glow);

  field.free();
  to.free();
  return from;
}

const imgA = Engine.loadImage(A);
const imgB = Engine.loadImage(B);
if (imgB.width !== imgA.width || imgB.height !== imgA.height) {
  imgB.resize(imgA.width, imgA.height);
}
const anim = Engine.animation(imgA.width, imgA.height, { loop: 0 });
const p = Engine.progress("Transition frames", { total: STEPS * 2 });

// There and back: the loop closes without a jump, and both directions show the effect.
for (const [first, second] of [[imgA, imgB], [imgB, imgA]]) {
  for (let i = 0; i < STEPS; i++) {
    const T = i / (STEPS - 1);
    const frame = transition(first.clone(), second.clone(), T);
    anim.addFrame(frame, { delay: i === STEPS - 1 ? HOLD_MS : DELAY_MS });
    frame.free();
    p.step(1, `frame ${i + 1}/${STEPS}`);
  }
}

anim.saveWebP(OUT, { lossy: true, quality: 62 });
anim.free();
imgA.free();
imgB.free();

// © 2026 Michael Lechner · mlc OpticScript · https://mlcgo.eu · Elastic License 2.0