fetched: what the heck, ship it

This commit is contained in:
mehbark 2023-09-23 14:22:01 -04:00
parent 85e2f718da
commit 0d90f710fe

View file

@ -14,12 +14,18 @@ const ctx = canvas.getContext("2d");
const default_fill = "#3B0920"; const default_fill = "#3B0920";
const bg_fill = "#FFE8D4"; const bg_fill = "#FFE8D4";
const border_stroke = "#83254F";
ctx.fillStyle = "#FFE8D4"; ctx.fillStyle = "#FFE8D4";
ctx.strokeStyle = "#83254F"; ctx.strokeStyle = border_stroke;
ctx.lineWidth = 10; ctx.lineWidth = 10;
ctx.fillRect(0, 0, 413, 413); ctx.fillRect(0, 0, 413, 413);
ctx.strokeRect(0, 0, 413, 413); ctx.strokeRect(0, 0, 413, 413);
const fix_border = () => {
ctx.strokeStyle = border_stroke;
ctx.strokeRect(0, 0, 413, 413);
};
const clear_rect = (x: number, y: number, w: number, h: number) => { const clear_rect = (x: number, y: number, w: number, h: number) => {
ctx.strokeStyle = ""; ctx.strokeStyle = "";
ctx.fillStyle = bg_fill; ctx.fillStyle = bg_fill;
@ -70,7 +76,7 @@ const secret_messages = [
"i prefer having things getting really really squishy to inserting newlines or-- perish the thought-- *actually being smart* I LIED AND DID IT RIGHT", "i prefer having things getting really really squishy to inserting newlines or-- perish the thought-- *actually being smart* I LIED AND DID IT RIGHT",
"i should make most of these short though", "i should make most of these short though",
"eggbug BONUS SECRET MESSAGE: eggbug TWO (pronounced like peggle TWO)", "eggbug BONUS SECRET MESSAGE: eggbug TWO (pronounced like peggle TWO)",
"this is literal cope but i love how messed up the text gets", "this is literal cope but i love how messed up the text gets (old message, things are a bit better now)",
"i think i'll make one hundred", "i think i'll make one hundred",
"who is your favorite homestuck troll? (i have a favorite)", "who is your favorite homestuck troll? (i have a favorite)",
"how do you feel about hiveswap?", "how do you feel about hiveswap?",
@ -115,8 +121,8 @@ const secret_messages = [
"JSX is so conceptually perfect that it has totally ruined other html templating for me", "JSX is so conceptually perfect that it has totally ruined other html templating for me",
"drink water or something", "drink water or something",
"FLKDHK: if you're reading this, go to pyrope.net/fetched.png and refresh until you see a message that starts with FLKDHK", "FLKDHK: if you're reading this, go to pyrope.net/fetched.png and refresh until you see a message that starts with FLKDHK",
"have you seen this post? cohost.org/mehbark/post/2902858-this-post", "have you seen this post? cohost.org/mehbark /post/2902858-this-post",
"you should go find the code together https://cohost.org/mehbark/post/2576955-find-the-code-togeth", "you should go find the code together cohost.org/mehbark /post/2576955-find-the-code-togeth",
"you should play pyrope.net/ew it's genuinely fun", "you should play pyrope.net/ew it's genuinely fun",
"odds are you are just a computer program... actually the odds are 100% really because browser etc etc", "odds are you are just a computer program... actually the odds are 100% really because browser etc etc",
"is the number goku yet? will the number ever be goku? dm me on discord @mehbark if it is", "is the number goku yet? will the number ever be goku? dm me on discord @mehbark if it is",
@ -201,7 +207,7 @@ function printAtWordWrap(
} }
} }
if (idx > 0) { if (idx > 0) {
context.fillText(words.join(" "), x, y + (lineHeight * currentLine)); context.fillText(words.join(" ") + " ", x, y + (lineHeight * currentLine));
} }
} }
@ -220,12 +226,6 @@ function draw_secret_message(message?: string) {
// ctx.fillText(, 10, 340, 395); // ctx.fillText(, 10, 340, 395);
} }
draw_times(999);
draw_times(1000);
draw_secret_message(secret_messages[secret_messages.length - 1]);
await Deno.writeFile("/tmp/canvas.png", canvas.toBuffer());
const kv = await Deno.openKv(); const kv = await Deno.openKv();
Deno.args.includes("--reset-count") && await kv.set(["fetched"], 0); Deno.args.includes("--reset-count") && await kv.set(["fetched"], 0);
@ -240,10 +240,12 @@ async function num_requests(): Promise<number> {
async function count_request() { async function count_request() {
await kv.set(["fetched"], await num_requests() + 1); await kv.set(["fetched"], await num_requests() + 1);
} }
Deno.serve({ port: 61261 }, async () => { Deno.serve({ port: 61261 }, async () => {
await count_request(); await count_request();
draw_times(await num_requests()); draw_times(await num_requests());
draw_secret_message(); draw_secret_message();
fix_border();
const image_format = "png"; const image_format = "png";
return new Response(canvas.toBuffer(), { return new Response(canvas.toBuffer(), {