Comments (7)
I'll work on this!
from pyknit.
It was indeed a font problem. I went for Courier New as that seems to be a good and universal monospace font. Here's the code I have so far for Chart.py
:
# draw symbol for each cell
fnt = ImageFont.truetype("Courier New.ttf", 40)
for i, stitch in enumerate(stitch_array):
draw.text(
((cell_width + 1) * i, 3), stitch, font=fnt, fill=(255, 255, 255, 255)
)
return chart_image
I tested it with this code:
pattern = "k1 p4 k1 p4 k kfb r ssk k2tog"
legend = {
"k": " ",
"p": ".",
"kfb": "\\/",
"ssk": "\\",
"k2tog": "k2tog",
"r": "r"
}
pattern_parsed = pyknit.parse_written(pattern, legend)
print(pattern_parsed)
pattern_printed = pyknit.print_chart(pattern_parsed)
pattern_printed.show()
I don't know how knitting patterns should look so I could do with some pointers here.
- I presume you intentionally want it to print
\/
and not\/
? Is that correct? k2tog
doesn't fit in the box at the moment. What would you like to do with that?
An example of input and desired output of print_chart
would help me here. Thanks.
from pyknit.
In a typical knitting chart, stitch symbols are a width that indicates either the starting or final size of the stitch. There's some sort of unspoken conventions about which ones are which, and I'm not sure I could articulate it (and different designers may prefer different things, hence why I'm starting with a legend rather than assuming a standard set of symbols)
- kfb is "knit front and back" and it takes a single stitch and turns it into two stitches. I've seen it represented a few ways and I was experimenting with how it worked. Probably the easiest thing to do for now is replace it in the legend with a
V
(looks like one stitch at the bottom and two at the top that way, and takes up one space). I have seen it listed as a two-space symbol too. - k2tog is "knit two together" and normally would be represented as
/
(I probably had not set this because I was experimenting with what would happen if my symbol was too large). It's a decrease stitch (take two stitches, turn them into one) but because people find it easier to "read" what it looks like on the final knitting, it's basically always represented as a single-wide symbol.
So this chart would likely be supposed to look something like...
.... .... Vr\/
Which is kind of a nonsense chart by itself, but could make sense as part of a longer pattern.
from pyknit.
My first try used standard keyboard symbols, but if you want to take a look at some more standard symbols, here's the list from the crafts americana website: https://www.craftyarncouncil.com/standards/knit-chart-symbols
Note that they use V
to represent "slip stitch" and don't have an explicit kfb symbol, but it would likely be a v
with a 2 over it, showing that you're increasing to two stitches.
I'm not sure what the best way to handle these in pyKnit is yet -- there are knitting symbol fonts but I didn't see one that looked like it had a license for redistribution with pyKnit, so we might want to import images/svg or draw them ourselves and find a way to specify 'use built-in symbol" in the legend.
from pyknit.
And also, this is looking great. Even if we only use standard font symbols to start, that can get you a pretty large range of patterns into a state where we can chart them!
from pyknit.
A thought: we are going to eventually want to make symbols that are more than one unit wide. We'll probably want the legend to have 3 parts, then: written instruction, symbol, width (possibly as start size/end size for calculating). It might be time to turn legend into some sort of more explicitly defined datatype.
from pyknit.
Closed thanks to @Ben-Hampson ! I'm going to open a new issue for improving our default stitch dictionary.
from pyknit.
Related Issues (20)
- Generate various component shapes HOT 4
- Drawn diagrams to help people understand measurements
- Read charts from .csv files (or other spreadsheet files?) HOT 2
- Create Pi Shawl function (and also half-pi) HOT 2
- Improve Jupyter-lab setup instructions HOT 1
- Set up doctests
- Add instructions for using pip install -e to README.md HOT 1
- Colour charts HOT 3
- Link to example notebook in docs HOT 1
- Update example notebook
- Extend default sitch dictionary & symbols we can draw
- pyknit.py main() fails to run HOT 3
- Convert error messages from print statements to error statements HOT 1
- Set up black to run in CI / pre-commit HOT 1
- do something fun with pyscript?
- Support for Japanese Chart Symbols HOT 5
- Estimate the time it would take to knit a pattern HOT 1
- Add error handling for nonsensical gauge swatches.
- Add error handling for nonsensical sleeves and increases HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyknit.