Back

Version 7

4/30/2024
/** @jsxImportSource https://esm.sh/preact */
import { Color } from "https://deno.land/x/color/mod.ts";
import { render } from "https://deno.land/x/resvg_wasm/mod.ts";
import { render as preact } from "npm:preact-render-to-string";

export default async function(req: Request): Promise<Response> {
const url = new URL(req.url);
const [a, b] = url.pathname.split("/").slice(1);

// if (!a || !b) return Response.json({ error: "Requires two colors" });

const size = 256;
const fontSize = 128;
const color = "#fff";
const bg = "#000";
const text = "Hi";

const svg = preact(
<svg
xmlns="http://www.w3.org/2000/svg"
width={size}
height={size}
viewBox={`0 0 ${size} ${size}`}
fill={color}
style={{
fontFamily: "sans-serif",
fontWeight: "bold",
fontSize,
}}
>
<rect
x="0"
y="0"
width={size}
height={size}
fill={bg}
jxnblk-contrast_swatch.web.val.run
Updated: April 30, 2024