Back

Version 19

1/24/2024
import { fetch } from "https://esm.town/v/std/fetch";

export let canvasText = async (req: Request) => {
const query = new URL(req.url).searchParams;
const { loadImage, createCanvas } = await import(
"https://deno.land/x/canvas/mod.ts"
);
const canvas = createCanvas(1200, 675);
const ctx = canvas.getContext("2d");

let canvasWidth = canvas.width;
let canvasHeight = canvas.height;
ctx.clearRect(0, 0, canvasWidth, canvasHeight);

const librelightres = await fetch(
`https://tomcritchlow.com/fonts/LibreFranklin-Light.ttf`,
);
const librelight = await librelightres.arrayBuffer();
canvas.loadFont(librelight, {
family: "Libre Franklin",
weight: "300",
});

const libresemiboldres = await fetch(
`https://tomcritchlow.com/fonts/LibreFranklin-SemiBold.ttf`,
);
const libresemibold = await libresemiboldres.arrayBuffer();
canvas.loadFont(libresemibold, {
family: "Libre Franklin",
weight: "600",
});

// Simple background
ctx.fillStyle = "#f1f1f1"; // Change to your preferred background color
ctx.fillRect(0, 0, canvasWidth, canvasHeight);

tomcritchlow-tom_og.web.val.run
Updated: March 6, 2024