Using Craft Anything to Build a Local Pen Plotter App from Plotropolis
How I used Craft Anything to inspect plotropolis.app and synthesize a zero-dependency, offline-capable local isometric city generator for pen plotters with hidden-line removal, hatching, and layered SVG export.
Pen plotters like the AxiDraw, iDraw, and NextDraw live and die by clean vector paths. Unlike laser printers or inkjets, a plotter cannot fill a polygon with a solid CSS color or rasterize a TrueType font—every surface tone has to be hatched with parallel pen strokes, every hidden edge behind a foreground building has to be clipped, and every pen-up travel move adds real mechanical time.
Plotropolis is a generative web app that builds dense isometric harbour cities and exports multi-pen, plot-ready SVGs. I wanted a local, offline-capable version I could run, inspect, and tweak on my own machine without relying on external hosting or tracking scripts.
Instead of manually reverse-engineering the bundle or scaffolding a fresh project from scratch, I pointed Craft Anything at https://plotropolis.app/ with a single prompt: “Can you make this run locally”—and let it investigate, extract, rebuild, and visually verify the entire application in plotropolis-app/.
1. The Craft Anything Workflow
Rather than blindly scraping HTML, Craft Anything runs a structured capture-and-synthesis pipeline tracked in craft.json and investigation.cany/:
https://plotropolis.app/
│
▼ 1. Capture & Trace (capture/)
├─ Multi-viewport screenshots (1440px, 768px, 390px)
├─ Interactive state snapshots (Foliage, Waterfront, View, Light & Hatching)
└─ Runtime analysis (how-it-works.md: 0 endpoints, 0 bundlers, pure client JS)
│
▼ 2. Modular Synthesis (app/src/)
├─ glyphs.js (single-stroke 4x6 Latin & 10x10 Kanji/icon vectors)
├─ engine.js (2.5D projection, HLR, scanline hatching, path sorting)
├─ city.js (seeded procedural zoning, buildings, waterfront, neon)
├─ ui.js (parameter controls, canvas preview, Inkscape SVG export)
└─ build.js (zero-dependency Node static bundler -> app/dist/)
│
▼ 3. Automated Visual Verification (craft.json)
└─ 98.6% similarity across 1440px / 768px / 390px + 14/14 claims passed
During the runtime trace (capture/how-it-works.md), Craft Anything observed the live page for 10 seconds across 1,285 DOM nodes and confirmed zero network API requests, zero backend routes, and zero external module bundlers—only pure client-side JavaScript and a single Cloudflare analytics beacon (which it stripped to keep the local build 100% offline-capable and private).
2. Zero-Dependency Static Architecture
Craft Anything organized the local rebuild under app/ using vanilla HTML5, CSS3, and ECMAScript 2022+ with no runtime frameworks or bundler bloat:
plotropolis-app/
├── app/
│ ├── build.js # Concatenates JS modules & copies assets to dist/
│ ├── package.json # `npm.cmd run build`
│ ├── src/
│ │ ├── index.html # App shell, controls sidebar, canvas viewport
│ │ ├── styles.css # Vellum/ink tokens & 860px mobile breakpoint
│ │ ├── favicon.svg # Vector favicon
│ │ └── js/
│ │ ├── glyphs.js # Single-stroke vector lettering & neon icons
│ │ ├── engine.js # Projection, HLR, hatching, path optimizer
│ │ ├── city.js # Procedural harbour city & district generator
│ │ └── ui.js # State manager, stats table, SVG exporter
│ └── dist/ # Static production output (index.html, app.js, styles.css)
├── capture/ # Reference screenshots, design tokens, trace logs
├── investigation.cany/ # Evidence & investigation journal
└── craft.json # Build status & visual verification report
app/build.js concatenates glyphs.js, engine.js, city.js, and ui.js in order into dist/app.js, patches the DOMContentLoaded bootstrap so it executes reliably regardless of script load timing, and copies index.html, styles.css, and favicon.svg into app/dist/.
3. How the Plotter Engine Works
Inspecting the generated app/src/js/ modules reveals the four core subsystems required to turn a 3D procedural city into clean plotter toolpaths.
2.5D Isometric Camera & Deterministic Seeding
In engine.js, makeCamera(thetaDeg, phiDeg, scale, ox, oy) projects world coordinates $(x, y, z)$ into screen space $(s_x, s_y)$ and depth $d$ using rotation angle $\theta$ (default $40^\circ$) and elevation tilt $\phi$ (default $30^\circ$):
Every city is driven by a deterministic mulberry32 PRNG seeded via hashInts(...), ensuring the exact same seed reproduces the exact same geometry, pen lifts, and ink lengths across sessions. For example, seed 1908 deterministically builds 162 buildings, 76 pieces of gear, and 13 non-repeating neon signs across 4 pen layers.
Hidden-Line Removal & Scanline Hatching
A pen plotter draws directly on paper, so lines behind foreground buildings cannot simply be painted over—they must be geometrically clipped against nearer occluders in Scene.
Once visible faces are resolved, solid tones and cast shadows are converted into parallel strokes by hatch2D(rings, angle, spacing, phase):
- Polygons are rotated into hatch-space, intersected with horizontal scanlines at
spacingintervals respecting the physical pen width (Math.max(0.3, opts.penWidth * 1.05)), and paired using the even-odd rule. mergeNear(paths, maxBridge)walks adjacent hatch segments and keeps the pen down across tiny gaps that land along the edge of the filled shape, cutting unnecessary pen lifts.simplify(p, tol)removes collinear intermediate vertices within tolerancetol.
TSP-Style Path Sorting & Plot Time Estimation
Randomly ordered hatch segments waste huge amounts of time lifting and slewing the plotter carriage. sortPaths(paths, start) runs a spatial-grid greedy nearest-neighbor search (CS = 10 mm grid cells) that inspects both endpoints of every remaining path, reversing a path in place if its tail is closer to the current pen position than its head.
showStats() in ui.js then computes per-pen ink length, pen-up travel before and after sorting, lift counts, and estimated plot duration at the configured drawing speed:
Single-Stroke Vector Typography (glyphs.js)
Because plotters cannot fill outline fonts, all neon rooftop signage and title typography use custom single-stroke polylines:
- Latin characters live on a $4 \times 6$ coordinate grid (
LATIN). - Kanji and neon icons (flamingo, guitar, cocktail, ramen, eye, bolt, cat, moon, palm) live on a $10 \times 10$ grid (
KANJI,ICONS), built from circular arcs (gArc), cubic Béziers (gBez), and Chaikin-smoothed polygons (chaikin). doubleTube(strokes, d)offsets strokes to create multi-pass neon tube lettering.
Inkscape-Layered SVG Export (ui.js)
svgText(only) outputs physical millimeter dimensions (width="${PW}mm" height="${PH}mm") and groups each pen into its own Inkscape-compatible layer (<g inkscape:groupmode="layer" id="1-..." inkscape:label="...">), allowing you to plot all four pens sequentially or export individual pen SVGs.
4. Visual Verification & Build Results
Craft Anything’s automated web-visual check compared the local app/dist/ build against the captured plotropolis.app baselines across desktop, tablet, and mobile viewports:
| Viewport | Layout Match | Overall Similarity | Page Height | Sideways Scroll |
|---|---|---|---|---|
| 1440 px (Desktop) | 100% | 96% | 900 vs 900 px | None |
| 768 px (Tablet) | 100% | 100% | 4874 vs 4874 px | None |
| 390 px (Mobile) | 100% | 100% | 4891 vs 4891 px | None |
All 14 functional and visual claims passed—including zero console errors, zero missing assets, exact vellum/ink/pen color tokens (#DCE2DE, #1A2B3C, #2450B8, #17854A, #D2232E, #1C1C22), and interactive accordion states (Foliage, Waterfront, View, Light and hatching)—with an overall similarity score of 98.62%.
To rebuild or run the local app at any time:
cd "C:\Users\hemal\Documents\Craft Anything\plotropolis-app\app"
npm.cmd run build
Then open app/dist/index.html directly in any browser—no server, no internet connection, and no external dependencies required.