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);
ctx.fillStyle = "#6CBE45";
ctx.beginPath();
ctx.arc(canvasWidth / 2, canvasHeight / 2, 300, 0, 2 * Math.PI);
ctx.fill();
const status = query.get("status");
if (status === "ok") {
ctx.fillStyle = "#ffffff";
ctx.font = "400 300px Arial";
ctx.fillText(":)", 400, 430);
} else {
ctx.fillStyle = "#ffffff";
ctx.font = "400 300px Arial";
ctx.fillText(":(", 400, 430);
}
return new Response(canvas.toBuffer(), {
headers: {
"Content-Type": "image/png",
},
});
};