You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A project in which I attempt to create a tool to help calculate knitting patterns.
3
-
My goal is to develop an app where the user can move and scale alpha patterns (patterns on a pixel grid) on a garment, and based on selected measurement, yarn gauge and pattern placement, the app can calculate a knitting pattern to follow.
1
+
```markdown
2
+
# 🧶 Knit App
3
+
4
+
## About This Project
5
+
Knit App is a comprehensive Streamlit-based application designed for knitters and compatible with crocheters and other textile makers. It bridges the gap between digital pixel art and physical garment construction. Users can upload images to generate alpha patterns, calculate garment shaping (Front, Back, and Sleeves) based on gauge and sizing, and edit multiple graphics on a digital canvas.
6
+
7
+
8
+
## Key Features
9
+
***Pattern Digitization:** Upload any PNG/JPG and use dynamic thresholding and resampling to convert it into a pixel matrix that you can layer onto a sweater canvas.
10
+
***Multi-Panel Garment IDE:** Switch between Front Panel, Back Panel, and Sleeves canvases that make up a drop shoulder sweater. The app dynamically calculates dimensions and short-row shaping based on user measurements and gauge.
11
+
***Layer Design Studio:** Add, duplicate, merge, and transform (rotate, flip, mirror, scale) multiple graphics on a single canvas.
12
+
***Fine-Tune Pixel Editor:** A built-in, manual spreadsheet-style editor to fine-tune individual stitches or draw custom motifs from scratch on blank 25x25 or 50x50 canvases.
13
+
***Alpha JSON exporter:** Export your custom design to a JSON file to reuse in future projects.
14
+
***Master PDF Compiler:** Automatically chunks your digital canvas into a printable PDF pattern complete with cast-on counts, row instructions, and sweater specs.
15
+
***Project Saving:** Serialize your entire workspace (including layers, settings, and math grids) into a JSON file to resume your work later.
16
+
17
+
18
+
## Prerequisites
19
+
Before installing, ensure you have **Python 3.9 or newer** installed on your system. We highly recommend using a virtual environment (like `venv` or Anaconda) to keep dependencies clean.
20
+
21
+
22
+
## Installation
23
+
24
+
### Option A: Using GitHub Desktop
25
+
1. Download and install [GitHub Desktop](https://desktop.github.com/).
26
+
2. Open GitHub Desktop and go to **File > Clone repository**.
27
+
3. Select the **URL** tab and paste: `https://github.com/Programming-The-Next-Step-2026/knitting_pattern.git`
28
+
4. Choose a local path on your computer and click **Clone**.
29
+
5. Open your preferred terminal (or Anaconda Prompt) and navigate to the folder you just cloned.
30
+
6. Run the following command to install the package and its dependencies:
31
+
pip install -e .
32
+
33
+
34
+
### Option B: Command Line (Windows / Mac / Linux)
Once installed, make sure your in the knitting_pattern directory, then run the application locally:
48
+
streamlit run src/knitting_pattern/app.py
49
+
50
+
This will automatically open the Knit App dashboard in your default web browser.
51
+
52
+
## Project Architecture
53
+
54
+
***`app.py`:** The Streamlit UI layer acting as the bridge for state management and user interaction.
55
+
***`math_engine.py`:** Calculates physical measurements, gauge conversions, and garment topography (like short row geometry).
56
+
***`image_engine.py`:** Handles digital formatting, utilizing Pillow and NumPy for image resampling, bounding box cropping, and Matplotlib for dynamic PDF generation.
57
+
58
+
## License
59
+
60
+
Distributed under the MIT License. Built for the course *Programming: The Next Step (2026)*.
"Knitting a custom sweater from the top down requires translating physical body measurements into a discrete grid of stitches and rows based on a individual knitting gauge. Manual conversion often leads to structural math errors. Furthermore, knitters wanting to incorporate multi-colored intarsia or stranded motifs (\"alpha patterns\") must manually map those pixel charts onto their specific garment dimensions, which is a slow and error-prone process.\n",
export_scaled=st.checkbox("Include Scale Multiplier?", value=False, help="Check this to download the physically enlarged matrix instead of the original size.")
st.markdown("<div style='margin-top: 28px;'></div>", unsafe_allow_html=True) # Pushes the button down to align with the slider
463
+
ifst.button("🔨 Bake", use_container_width=True, help="Permanently enlarge the pixel matrix so you can edit the scaled pixels individually.", key=f"bake_{idx}_{pk}_{active_panel}"):
0 commit comments