A browser-based tool for creating vector polygon graphics for games (like Asteroids). Users plot vertices on a grid and export as Lua flat arrays.
index.html— Single-page app (HTML/CSS/JS), loadsvector.jsvia script tagvector.js— Pure logic module shared between app and tests. Exports viamodule.exportsfor Node, global functions for browsertests.js— Node-based test suite for all pure logic
node tests.js
All tests must pass before considering work complete. Run tests after every change to vector.js or logic in index.html.
- No build tools, no frameworks, no dependencies
- Pure functions live in
vector.js— keep them pure (no DOM, no global state) index.htmluses wrapper functions (_gridToCanvas,_canvasToGrid,_getEffectiveVertices) that bind app state to shared pure functions- Coordinate system: (0,0) at grid center, snap-to-grid only
- Alistair Cockburn fully-dressed use cases live in
use-cases/(UC-01 through UC-13) - Every feature request or bug fix must include a review of affected use cases — update existing ones or create new ones as needed
- New use cases follow the naming convention
UC-NN-short-description.md - Use cases are the source of truth for expected behavior; code and tests must stay consistent with them
- After every change (code, tests, use cases, or documentation), prompt the user: "Would you like to commit this change to version control?"
- Do not commit automatically — always ask first
gridToCanvas(gx, gy, originX, originY, cellSize)— grid coords to canvas pixelscanvasToGrid(cx, cy, originX, originY, cellSize, gridSize)— canvas pixels to snapped grid coordsrotatePoint(x, y, angleDeg)— rotate point around origingetEffectiveVertices(vertices, mirrorX, mirrorY)— apply mirror modes, returns new arrays (no mutation)parseLuaTable(text)— parse Lua flat array to vertex pairs, returns null on invalid inputgenerateLuaOutput(vertices, scaleFactor)— generate Lua flat array stringtranslateVertices(vertices, dx, dy, gridSize)— shift all vertices by delta, clamped to grid boundsclampRotation(value)— parse and clamp rotation input to integer 0–360
- Lua output format: flat array
vertices = { x1, y1, x2, y2, ... } - New pure logic goes in
vector.jswith corresponding tests intests.js - DOM/canvas code stays in
index.html