opsCanvas

import {
  createOpsCanvas,
  FillShapesGridLayoutValues,
  FillShapesGridShapeValues,
} from "@ops/canvas";
import { lerp, Ranges } from "@ops-utils/math";

const canvasSize = Math.round(parseFloat(Deno.args[1]));
const fontSize = 18;

const canvas = createOpsCanvas(fontSize + 1, fontSize + 1);
canvas.setColor("black");

canvas.seededNoise.setSeed(`sfdsdfsdf10`);

canvas.drawText("b", {
  size: fontSize,
  x: canvas.getRel(0.5, "relativeX") + 0.02,
  y: canvas.getRel(0.5, "relativeY"),
  color: "white",
  baseline: "middle",
  align: "center",
});

canvas.trim({ padding: 1, threshold: 120, channel: "b" });
canvas.invert();
canvas.fillBackground("white");

canvas.resize(
  canvasSize * (canvas.getWidth() / canvas.getHeight()),
  canvasSize,
  "nearest",
);

const result = canvas.clone();
result.setColor("white");

for (const range of Ranges.getMinMaxSteps(0, 254, 20)) {
  const stepCanvas = canvas.clone();
  stepCanvas.thresholdBounds(range.start, range.end, "r", "a");
  stepCanvas.set(255, "rgb");

  // const lineWidth = lerp(14, 1, Math.pow(range.relativeIndex, 1.1));
  const shapeSize = lerp(
    result.getRel(0.2, "relativeMin"),
    result.getRel(0.01, "relativeMin"),
    Math.pow(range.relativeIndex, 1.1),
  );

  const shapeSpacing = lerp(
    result.getRel(-0.02, "relativeMin"),
    result.getRel(0.04, "relativeMin"),
    Math.pow(range.relativeIndex, 1.1),
  );

  stepCanvas.fills.shapesGrid({
    shapeSize: shapeSize,
    spacing: shapeSpacing,
    shape: canvas.seededNoise.getRandomFromArray(FillShapesGridShapeValues),
    layout: canvas.seededNoise.getRandomFromArray(
      FillShapesGridLayoutValues,
    ),
    mask: "rgb",
    color: "black",
  });

  result.blend(stepCanvas, 0, 0);
}

result.grow(canvasSize, canvasSize, "once", { center: true });
result.fillBackground("white");

Deno.writeFileSync(Deno.args[0], result.toPngBuffer());
mod.ts