A town simulation in pale isometric line art, implemented with Ritmo ECS and PixiJs 3D
Tighter share limits: town 100 KB, picture 500 KB, JPEG at 0.78
SandroMaglioneb561dff2ba64
diff --git a/DEVELOPMENT.md b/DEVELOPMENT.mdindex e6417bf..85f9ed4 100644--- a/DEVELOPMENT.md+++ b/DEVELOPMENT.md@@ -280,7 +280,7 @@ and `towns/<id>.picture`:| route | does ||---|---|-| `POST /api/towns` | checks the town is gzip under 400 KB, the picture a JPEG/PNG/WebP under 600 KB, and the lines short and plain; keeps them under a new id |+| `POST /api/towns` | checks the town is gzip under 100 KB, the picture a JPEG/PNG/WebP under 500 KB, and the lines short and plain; keeps them under a new id || `GET /api/towns/<id>` and `/picture` | the files as kept, cached for a year (shares never change) || `GET /t/<id>` | the game's `index.html` with the share's Open Graph and Twitter tags written in, so links unfurl to the card |diff --git a/src/host.ts b/src/host.tsindex 49eb3ea..7beb942 100644--- a/src/host.ts+++ b/src/host.ts@@ -57,7 +57,7 @@ import { emptyPreview } from "./ui.ts"import { GameScene, type CameraView } from "./render3d/scene.ts"import { blobOf, cardFacts, drawCard, metaOf, scaled, verdictOf } from "./share/card.ts"import { handheld, offerLink, offerPicture, upload } from "./share/client.ts"-import { PICTURE_HEIGHT, PICTURE_WIDTH } from "./share/format.ts"+import { PICTURE_HEIGHT, PICTURE_QUALITY, PICTURE_WIDTH } from "./share/format.ts"import { MapInput } from "./render3d/input.ts"const el = <K extends keyof HTMLElementTagNameMap>(tag: K, className: string, text = "") => {@@ -1373,7 +1373,7 @@ export const createHost = async (mount: HTMLElement, persistence: () => Persistelink.disabled = truelink.lastChild!.textContent = "Making a link…"try {- const small = await blobOf(scaled(card, PICTURE_WIDTH, PICTURE_HEIGHT), "image/jpeg", 0.86)+ const small = await blobOf(scaled(card, PICTURE_WIDTH, PICTURE_HEIGHT), "image/jpeg", PICTURE_QUALITY)const made = await upload(persistence().shareFile(stage.view()), small, metaOf(facts))link.remove()const field = document.createElement("input")diff --git a/src/share/format.ts b/src/share/format.tsindex 00492dd..249937f 100644--- a/src/share/format.ts+++ b/src/share/format.ts@@ -21,9 +21,16 @@ export const sharePath = (id: string) => `/t/${id}`export const townPath = (id: string) => `/api/towns/${id}`export const picturePath = (id: string) => `/api/towns/${id}/picture`-/** The largest town and picture the server takes: a full large town gzips to a tenth of this. */-export const TOWN_LIMIT = 400_000-export const PICTURE_LIMIT = 600_000+/**+ * The largest town and picture the server takes. A real town gzips to 4 KB+ * when founded and about 26 KB after 50 minutes on large land; its picture+ * is 100 to 200 KB. The limits leave room above that and no more, since+ * they bound what the bucket can be made to hold.+ */+export const TOWN_LIMIT = 100_000+export const PICTURE_LIMIT = 500_000+/** JPEG quality of the uploaded picture: a preview card shows no difference from higher, and it is about a fifth smaller. */+export const PICTURE_QUALITY = 0.78/** The picture's size: what link previews expect. */export const PICTURE_WIDTH = 1200export const PICTURE_HEIGHT = 630