A package for parsing and converting knitted lace patterns
Project description
LoveLaceMK
A Python package for parsing and converting knitted lace patterns
This package takes written instructions or charts for hand-knitted lace and converts them to a rendered chart, AYAB file, or punchcard for machine knitting.
Installation
Install with pip:
pip install lovelacemk
Usage
Input
The input file can be in one of two formats, specified by the --type argument: instructions (default), or chart.
Instructions
A set of written instructions for hand knitting can be parsed, for example k1, yo, k3, ssk, k1. The instructions it accepts are intended to match those found in A Second Treasury of Knitting Patterns by Barbara Walker, but it is intentionally broad in the formatting it accepts. For example, sl k2tog psso, sl1-k2 tog-psso, and slip 1 - knit 2 together - pass slipped stich over will all be interpreted correctly.
Chart
A typed-out chart can also be accepted, such as the one below (for the Ivy Leaf pattern taken from A Second Treasury of Knitting Patterns):
.o.....\./o.............o\./.....o.
.o....\./oo^oo^oo^oo^oo^oo\./....o.
.o...\./o......o\./o......o\./...o.
.o..\./oo^oo^oo\.../oo^oo^oo\./..o.
.o.\./oo\./o.o\...../o.o\./oo\./.o.
.o\/o....../o\..o.o../o\......o\/o.
..o^o.o\./......o.o......\./o.o^o..
.......o\./.....o.o.....\./o.......
/oo^oo^oo\./....o.o....\./oo^oo^oo\
./o......o\./...o.o...\./o......o\.
../oo^oo^oo\./..o.o..\./oo^oo^oo\..
.../o.o\./oo\./.o.o.\./oo\./o.o\...
.o../o\......o\/o.o\/o....../o\..o.
.o......\./o.o^o...o^o.o\./......o.
The following symbols are recognised:
- Yarn over:
o,O,0 - Left-leaning decrease (ssk):
\\ - Right-leaning decrease (k2 tog):
/ - Double decrease (sl1-k2tog-psso):
^,X,x - Knit:
(space),.,-
The chart output from lovelacemk can also be read as input.
Output
Chart (rendered)
Passing an SVG file (or a file with no extension) to the --chart option will cause the lace chart to be rendered as an SVG to this file.
Chart (text)
Passing any other file type to the --chart option will cause the lace chart to be written in plain text, in the same format as the example above.
AYAB
The lace pattern can be rendered to an image suitable for use with AYAB by passing an image file path to the --ayab option. The file will indicate when to knit with the main carriage by including two blank rows; when the lace carriage does not select anything on a left-to-right pass, and does not select anything on the next right-to-left pass, two rows should be knitted with the main carriage.
Punchcard
The lace pattern can be written to a text file in the format required for Brenda Bell's Punchcard Generator, by passing a file path to the --punchcard option. No checks are performed to verify that the lace pattern is suitable for a punchcard.
Example
For an example of the input and output, see the (example)[/example]. The input file was copied directly from A Second Treasury of Knitting Patterns, and the output generated with the following two commands:
python3 -m lovelacemk -i ivy_leaf.txt -c chart.svg -a ayab.png -p punchcard.txt
# once more to generate the text-based chart
python3 -m lovelacemk -i ivy_leaf.txt -c chart.txt
When copying and pasting written instructions, be careful that characters are copied directly. Some PDF readers might misinterpret sl as s1 or si, and k1 as kl etc.
Limitations
Since this tool is primarily aimed at machine knitting, there are some limitations:
- All rows must have the same number of stitches
- For chart input, there is no distinction between the types of double decrease (e.g. sl 2 - k1 - psso, sl 1 - k2 tog - psso, or k3 tog). They are all treated as sl 1 - k2 tog - psso, since this is the easiest to replicate on a knitting machine. They are, however, interpreted correctly from written instructions.
- Currently, this package has no concept of purl stitches. For hand knitting instruction input, it assumes that every instruction row is for the right side, with an implied row of plain purls between each instruction row.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lovelacemk-0.1.0.tar.gz.
File metadata
- Download URL: lovelacemk-0.1.0.tar.gz
- Upload date:
- Size: 28.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d01b3f3e16e8641f42c1f616e6c92a00bd04f5f9b9c3368247b75809ab09fb1
|
|
| MD5 |
1ac15dc54d7d0640691be56935c6ecc9
|
|
| BLAKE2b-256 |
6be70b8f349951122814d64f1725cbb1fc1ec7d4c9d43a46a0e4384e897b53a7
|
File details
Details for the file lovelacemk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: lovelacemk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 22.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
75d27fcf1fa04f7855e2c40421097c12e7ef3e155ca3f318952ba7b377388e3b
|
|
| MD5 |
59f9de3360576f374b542db6986e768b
|
|
| BLAKE2b-256 |
f8253824aa9df00979428bf70eacd1ef8689eb066d83868205d48450b47ee503
|