How jamestomasino/stitchy works
Purpose
Stitchy is a browser-based crochet-pattern generator. It lets a user place an uploaded image over a rectangular grid, transform it, reduce each grid cell to a color treatment, manually adjust cells, and print/save the resulting pattern.
Entry Point and Runtime
index.html is the application entry point and hosts the UI plus the drawing surface. The app runs entirely in the browser with client-side JavaScript and CSS:
• index.html
• scripts.js
• styles.css
There is no server-side code, database, build system, or deployment infrastructure represented in the repository.
UI and Pattern Workspace
The page provides controls for defining grid dimensions, loading an image, selecting processing behavior, and output actions. styles.css owns presentation while scripts.js coordinates UI events with canvas/grid updates.
• index.html
• styles.css
• scripts.js
Grid and Image-Transformation Stage
The central workspace is a grid overlaid on an image. User-controlled rotate, scale, and transform operations determine how source pixels align with grid cells before pattern generation. This stage is the key boundary between source-image manipulation and discrete stitch-cell output.
• scripts.js
• index.html
Color Sampling and Cell Rendering
Pattern processing converts image areas corresponding to grid blocks into rendered cell colors. Supported modes include black-and-white conversion and dominant-color extraction per block. The resulting grid is the editable, printable artifact.
• scripts.js
• color-thief.umd.js
• nearestColor.js
Palette Quantization and Manual Editing
Dominant/sample colors are mapped to usable palette colors through the bundled nearest-color implementation. Rendered cells can then be clicked to cycle through palette options, allowing manual correction after automated processing.
• nearestColor.js
• scripts.js
External Client-Side Libraries
The repository includes local browser-ready color-processing libraries:
• color-thief.umd.js supplies dominant-color extraction.
• nearestColor.js supplies nearest-palette matching.
The README also identifies Konva as the canvas/interaction library used by the application; its integration is expected through the page/scripts rather than a tracked package manifest.
• color-thief.umd.js
• nearestColor.js
• index.html
Output Boundary
The final rendered grid is exported through browser print/save behavior. Output is generated from the client-side workspace rather than persisted to a backend.
• scripts.js
• index.html
Main entry points: scripts.js Block color sampling · index.html Application page · styles.css Presentation · color-thief.umd.js Dominant color extractor
Components 12
Browser application
Entire application runs client-side.
- Application page · Hosts controls and drawing surface.
index.html - Pattern controls · Grid, image, processing, and output controls.
index.html - Presentation
styles.css - App coordinator · Coordinates events, canvas updates, editing, and output.
scripts.js - Print / save · Exports the client-side rendered pattern.
scripts.js
Pattern processing
Transforms source imagery into editable stitch cells.
- Uploaded image
index.html - Image transform · Applies rotation, scale, and positioning before sampling.
scripts.js - Block color sampling · Converts image blocks into black-and-white or dominant colors.
scripts.js - Dominant color extractor
color-thief.umd.js - Palette matcher · Maps sampled colors to nearest palette colors.
nearestColor.js - Editable stitch grid · Printable cell-based pattern artifact.
scripts.js - Cell correction · Cycles a cell through palette options.
scripts.js
Connections 14
- Application page → Pattern controls: hosts
- Application page → App coordinator: loads
- Application page → Presentation: applies
- Pattern controls → Uploaded image: selects
- Pattern controls → App coordinator: events
- Uploaded image → Image transform: image
- App coordinator → Image transform: controls
- Image transform → Block color sampling: aligned pixels
- Block color sampling → Dominant color extractor: extracts dominant colors
- Block color sampling → Palette matcher: matches palette
- Block color sampling → Editable stitch grid: renders cells
- Editable stitch grid → Cell correction: clickable cells
- Cell correction → Editable stitch grid: updates color
- Editable stitch grid → Print / save: print / save