From d106823e1959e8aefb93363ef7eaa578d7b057cf Mon Sep 17 00:00:00 2001 From: Tangent Wantwight Date: Fri, 12 Jan 2024 20:21:58 -0500 Subject: [PATCH] sketchout a canvas applet --- island.html | 11 +++++++++++ island.ts | 25 +++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 island.html create mode 100644 island.ts diff --git a/island.html b/island.html new file mode 100644 index 0000000..bdf91a7 --- /dev/null +++ b/island.html @@ -0,0 +1,11 @@ + + + ProcGen Island + + + + + + diff --git a/island.ts b/island.ts new file mode 100644 index 0000000..43e0f6d --- /dev/null +++ b/island.ts @@ -0,0 +1,25 @@ +const BLOWUP = 4; +const WIDTH = 240; +const HEIGHT = 135; + +export function IslandApplet() { + const canvas = Object.assign(document.createElement("canvas"), { + width: WIDTH * BLOWUP, + height: HEIGHT * BLOWUP, + } satisfies Partial); + + const cx = canvas.getContext("2d"); + if (!cx) { + throw new Error("2D rendering context not supported"); + } + cx.scale(BLOWUP, BLOWUP); + + cx.fillStyle = "red"; + cx.fillRect(0, 0, WIDTH, HEIGHT); + cx.fillStyle = "blue"; + cx.fillRect(1, 1, WIDTH - 2, HEIGHT - 2); + + return [canvas]; +} + +(globalThis as any).IslandApplet = IslandApplet;