Skip to content

Commit 9746ea4

Browse files
authored
Merge pull request #4 from Programming-The-Next-Step-2026/week-3
readme
2 parents eb2c15a + 87e7e58 commit 9746ea4

30 files changed

Lines changed: 1846 additions & 773 deletions

.DS_Store

0 Bytes
Binary file not shown.

.coverage

52 KB
Binary file not shown.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# knitting_pattern
2+
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.

README.md

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,60 @@
1-
# knitting_pattern
2-
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)
35+
1. Open your Terminal/Command Prompt/PowerShell.
36+
2. Clone the repository:
37+
git clone [https://github.com/Programming-The-Next-Step-2026/knitting_pattern.git](https://github.com/Programming-The-Next-Step-2026/knitting_pattern.git)
38+
39+
3. Navigate into the directory:
40+
cd knitting_pattern
41+
42+
4. Install the package:
43+
pip install -e .
44+
45+
46+
## Usage
47+
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)*.

app_generated_chart.png

-61.9 KB
Loading

docs/.ipynb_checkpoints/report-checkpoint.ipynb

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,23 @@
2020
"source": [
2121
"2. Software Architecture\n",
2222
"The software uses the standard Python src/ layout to isolate core business and graphical logic from the presentation layer.\n",
23+
"\n",
24+
"Stitch and Row Allocation: The engine converts user dimensions (in centimeters) to absolute integers. \n",
25+
"It uses ceiling rounding (math.ceil) since a knitter cannot execute a partial stitch. The underlying formula is:\n",
26+
"stitches = [{width (cm)} * {stitch gauge} / 10)]\n",
27+
"\n",
28+
"Grid Canvas Representation: The backend models the fabric as a two-dimensional grid (nested lists or arrays). Unoccupied background fabric is initialized to 0.\n",
29+
"Alpha Pattern Integration: The system reads pixel-based assets representing the alpha design. It maps these coordinates directly onto the sweater grid, reassigning target cells from background 0 to specific integer color IDs (e.g., 1, 2, 3). This acts as the layout for the color chart."
30+
]
31+
},
32+
{
33+
"cell_type": "code",
34+
"execution_count": null,
35+
"id": "cc4d6fcd-c5f0-4b80-b409-8c4fc66b0922",
36+
"metadata": {},
37+
"outputs": [],
38+
"source": [
39+
"Current layout:\n",
2340
"knitting_pattern/\n",
2441
"├── src/\n",
2542
"│ ├── knitting_pattern/\n",
@@ -29,13 +46,7 @@
2946
"│ │ └── image_engine.py # Visualization logic, plotting chart and recognizing alpha patterns\n",
3047
"│ └── tests/\n",
3148
"│ ├── test_image_engine.py\n",
32-
"│ └── test_math_engine.py \n",
33-
"Stitch and Row Allocation: The engine converts user dimensions (in centimeters) to absolute integers. \n",
34-
"It uses ceiling rounding (math.ceil) since a knitter cannot execute a partial stitch. The underlying formula is:\n",
35-
"stitches = [{width (cm)} * {stitch gauge} / 10)]\n",
36-
"\n",
37-
"Grid Canvas Representation: The backend models the fabric as a two-dimensional grid (nested lists or arrays). Unoccupied background fabric is initialized to 0.\n",
38-
"Alpha Pattern Integration: The system reads pixel-based assets representing the alpha design. It maps these coordinates directly onto the sweater grid, reassigning target cells from background 0 to specific integer color IDs (e.g., 1, 2, 3). This acts as the layout for the color chart."
49+
"│ └── test_math_engine.py "
3950
]
4051
},
4152
{

docs/report.ipynb

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
"id": "73620923-8165-4d80-a81a-cb768294cc6f",
66
"metadata": {},
77
"source": [
8-
"Week 3 Assignment: Knitting Pattern Calculator Project Report\n",
9-
"\n",
108
"1. Project Overview\n",
119
"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",
1210
"\n",
@@ -20,6 +18,23 @@
2018
"source": [
2119
"2. Software Architecture\n",
2220
"The software uses the standard Python src/ layout to isolate core business and graphical logic from the presentation layer.\n",
21+
"\n",
22+
"Stitch and Row Allocation: The engine converts user dimensions (in centimeters) to absolute integers. \n",
23+
"It uses ceiling rounding (math.ceil) since a knitter cannot execute a partial stitch. The underlying formula is:\n",
24+
"stitches = [{width (cm)} * {stitch gauge} / 10)]\n",
25+
"\n",
26+
"Grid Canvas Representation: The backend models the fabric as a two-dimensional grid (nested lists or arrays). Unoccupied background fabric is initialized to 0.\n",
27+
"Alpha Pattern Integration: The system reads pixel-based assets representing the alpha design. It maps these coordinates directly onto the sweater grid, reassigning target cells from background 0 to specific integer color IDs (e.g., 1, 2, 3). This acts as the layout for the color chart."
28+
]
29+
},
30+
{
31+
"cell_type": "code",
32+
"execution_count": null,
33+
"id": "cc4d6fcd-c5f0-4b80-b409-8c4fc66b0922",
34+
"metadata": {},
35+
"outputs": [],
36+
"source": [
37+
"Current layout:\n",
2338
"knitting_pattern/\n",
2439
"├── src/\n",
2540
"│ ├── knitting_pattern/\n",
@@ -29,13 +44,7 @@
2944
"│ │ └── image_engine.py # Visualization logic, plotting chart and recognizing alpha patterns\n",
3045
"│ └── tests/\n",
3146
"│ ├── test_image_engine.py\n",
32-
"│ └── test_math_engine.py \n",
33-
"Stitch and Row Allocation: The engine converts user dimensions (in centimeters) to absolute integers. \n",
34-
"It uses ceiling rounding (math.ceil) since a knitter cannot execute a partial stitch. The underlying formula is:\n",
35-
"stitches = [{width (cm)} * {stitch gauge} / 10)]\n",
36-
"\n",
37-
"Grid Canvas Representation: The backend models the fabric as a two-dimensional grid (nested lists or arrays). Unoccupied background fabric is initialized to 0.\n",
38-
"Alpha Pattern Integration: The system reads pixel-based assets representing the alpha design. It maps these coordinates directly onto the sweater grid, reassigning target cells from background 0 to specific integer color IDs (e.g., 1, 2, 3). This acts as the layout for the color chart."
47+
"│ └── test_math_engine.py "
3948
]
4049
},
4150
{
@@ -71,6 +80,22 @@
7180
"\n",
7281
"Solution: Expand the mathematical backend to calculate complex raglan lines and set-in sleeve caps. This requires developing dynamic decrease formulas to scale diagonal stitch lines across the grid canvas while maintaining the integrity of the centered alpha patterns."
7382
]
83+
},
84+
{
85+
"cell_type": "markdown",
86+
"id": "e66e80a0-6441-43dd-b2bc-04f0bb39cc53",
87+
"metadata": {},
88+
"source": [
89+
"Things to implement before Friday:\n",
90+
"1. manual pixel editor in case the pixel converter isnt perfect (still in developement - prototype exists)\n",
91+
"2. sleeves (DONE)\n",
92+
"3. multiple alpha patterns on one thing - to edit them you click on the sidepanel on one of the alpha patterns and edit like normal. (DONE)\n",
93+
"5. Be able to copy an alpha pattern for continuous 'stripe' or to make a repeating pattern (maybe through the multiple alpha pattern added or have like a choice to make a vertical or horizontal repeating pattern from one alpha pattern? maybe even a hexagonal grid, square grid? offset vertical stripes over some parts of the sweater? (DONE)\n",
94+
"6. make more unit tests that have good coverage (see julians comments) (no progress)\n",
95+
"7. have the whole pattern in one pdf; so be able to have separate 'projects' at once: front panel, back panel, and sleeves. so we can design alpha patterns and fit for each aspect of the sweater and then put everything in one pdf pattern with the title of the project that we chose and the rest of the instructions. (DONE)\n",
96+
"8. save JSON file of current session so you don't loose progress and can import the JSON file to start back on (DONE)\n",
97+
"9. README file update to include the instructions of download and use. (no progress)"
98+
]
7499
}
75100
],
76101
"metadata": {

pyproject.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ description = "Kitting pattern calculator tool for my programming course"
1515
readme = "README.md"
1616
requires-python = ">=3.9"
1717
dependencies = [
18-
"numpy",
19-
"Pillow",
20-
"streamlit",
21-
"matplotlib"
18+
"numpy>=1.24.0",
19+
"Pillow>=9.1.0",
20+
"streamlit>=1.30.0",
21+
"matplotlib>=3.5.0",
22+
"pandas>=1.5.0"
2223
]
2324
classifiers = [
2425
"Programming Language :: Python :: 3",

src/.DS_Store

0 Bytes
Binary file not shown.

src/all_over_pattern.jpg

148 KB
Loading

0 commit comments

Comments
 (0)