Alle PhotoCraft-Filter auf einem Bogen

Wendet alle 112 PhotoCraft-Filter — Filter-Menü plus die 47 Effekte der Filter-Galerie — mit Standardwerten auf einen quadratischen Ausschnitt an und ordnet sie beschriftet und nach Kategorie sortiert im Raster an.

INPUT
INPUT — Alle PhotoCraft-Filter auf einem Bogen
OUTPUT
OUTPUT — Alle PhotoCraft-Filter auf einem Bogen
JavaScript
// Every PhotoCraft filter on one sheet — Filter menu + Filter Gallery, with default settings
// demo_photocraft_all.js
//!INPUT: INPUT
//!OUTPUT: OUTPUT
//!PARAM: KIND:string=all, BG_COLOR:string=#1a1a2e
//!PARAM: TILE:integer=160,min=48,max=1024, COLS:integer=12,min=1,max=40

// Applies every filter from Engine.filters() with its default parameters to a square
// crop of the input and lays the results out in a labelled grid, sorted by category.
//
//   KIND      "all" | "filter" (Filter menu) | "gallery" (Filter Gallery effects)
//   TILE      tile size in pixels (labels scale with it)
//   COLS      tiles per row
//
// Labels are SVG text rendered via Engine.loadSVG (system fonts).
// Displace and Lens Blur get a blurred copy of the tile as displacement / depth map.

const T    = Math.max(48, Math.round(TILE));
const N    = Math.max(1, Math.round(COLS));
const GAP  = Math.max(4, Math.round(T / 20));
const LBL  = Math.max(9, Math.round(T / 13)) + 2 * GAP; // label strip height

// ── Source: square centre crop, T×T ────────────────────────────────────────
const src = Engine.loadImage(INPUT);
const k = T / Math.min(src.width, src.height);
src.resize(Math.max(T, Math.round(src.width * k)), Math.max(T, Math.round(src.height * k)));
src.crop(Math.floor((src.width - T) / 2), Math.floor((src.height - T) / 2), T, T);
const map = src.clone().gaussianBlur(T / 16);

// ── Filters, grouped: Filter menu by category, then the Filter Gallery ─────
const order = f => (f.kind === "filter" ? "0" : "1") + f.category;
const filters = Engine.filters({ source: "pc" })
  .filter(f => f.kind !== "stack" && (KIND === "all" || f.kind === KIND))
  .sort((a, b) => order(a).localeCompare(order(b)));
const tiles = [{ label: "ORIGINAL", kind: "", img: src.clone() }];
for (const f of filters) {
  const img = src.clone();
  try {
    if (f.kind === "gallery") img.gallery(f.name);
    else if (f.name === "displace") img.filter(f.name, { map });
    else if (f.name === "lensBlur") img.filter(f.name, { depth: map });
    else img.filter(f.name);
  } catch (e) {
    console.error(`${f.name}: ${e.message}`);
    img.tint("#ff0000", 0.6);
  }
  tiles.push({ label: f.label, kind: f.kind, img });
}

// ── Sheet: background + labels as one SVG (rendered with system fonts), tiles on top ──
const FS  = Math.max(9, Math.round(T / 13));       // label font size
const CW = T + GAP;
const CH = T + LBL;
const rows = Math.ceil(tiles.length / N);
const W = GAP + Math.min(N, tiles.length) * CW;
const H = GAP + rows * CH;
const COLOR = { "": "#8fd18f", filter: "#d8dce8", gallery: "#f2c46d" };
const esc = s => s.replace(/&/g, "&amp;").replace(/</g, "&lt;");

let svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${W}" height="${H}">` +
  `<rect width="${W}" height="${H}" fill="${BG_COLOR || "#1a1a2e"}"/>` +
  `<g font-family="sans-serif" font-size="${FS}" text-anchor="middle">`;
tiles.forEach((t, i) => {
  const x = GAP + (i % N) * CW + T / 2;
  const y = GAP + Math.floor(i / N) * CH + T + GAP + FS;
  // squeeze labels that would overflow the tile width
  const fit = t.label.length * FS * 0.55 > T - 4 ? ` textLength="${T - 4}" lengthAdjust="spacingAndGlyphs"` : "";
  svg += `<text x="${x}" y="${y}" fill="${COLOR[t.kind]}"${fit}>${esc(t.label)}</text>`;
});
svg += "</g></svg>";
const sheet = Engine.loadSVG(svg);

tiles.forEach((t, i) => {
  sheet.blendAt(t.img, px(GAP + (i % N) * CW, GAP + Math.floor(i / N) * CH), 1.0, BlendMode.Over);
  t.img.free();
});
map.free();
src.free();

console.log(`${tiles.length - 1} filters (white = Filter menu, gold = Filter Gallery)`);
sheet.save(OUTPUT);