Comments (5)
I've noticed that in Chart.py, there is a comment here:
class Stitch:
"""A class to represent a stitch. Optionally, a preferred legend can be passed in."""
I'd love more information on how to optionally pass in a custom legend. I'm still going to create the japanese symbol legend, but I'd like to know more about that
from pyknit.
This sounds like a great idea!
The legend is currently pretty basic. You can see how it's set up in Chart.py. Here's a snippet:
stitch_legend = { # Default legend. Incomplete for now.
"ssk": Stitch(
instruction="slip slip knit", # left-leaning decrease
symbol="\\",
width=1,
),
"C1-1L": Stitch(
instruction="sl 1st onto cn, with cn in front, k1, k1 from cn",
symbol=os.path.join(symbol_dir, "C1-1L.png"),
width=2,
}
}
So basically you'd just want to replace the symbols you don't like with the ones you like. You can over-ride them or make a whole new default legend with the symbols that you wanted.
I think it would be pretty cool to have both the craft yarn council symbols we're currently using and the Japanese ones set up in the code. There's two options for how we'd store those off the top of my head:
- Make our big default legend store multiple symbol options and set symbol to the one in current use.
e.g.
"C1-1L": Stitch(
instruction="sl 1st onto cn, with cn in front, k1, k1 from cn",
symbol_cyc1=os.path.join(symbol_dir, "C1-1L.png"),
symbol_japanese=os.path.join(japanese_symbol_dir, "C1-1L.png"),
symbol=symbol_cyc1,
width=2,
}
Or something with some more syntactic elegance so you could have symbol['japanese']
and maybe something so you wouldn't have to typing out the os.path.join()
stuff, but the general idea is that you'd easily be able to switch between a few common symbols as part of the default library.
- Store the symbols in separate libraries
Same deal only the symbols would each be their own thing, so you'd refer to those directly:
"C1-1L": Stitch(
instruction="sl 1st onto cn, with cn in front, k1, k1 from cn",
symbol=japanese_symbols['C1-1L'],
width=2,
}
Same deal, only here we'd have to be a bit careful about making sure multiple symbol libraries have the same keys so that we could switch between them easily, which might be a pain.
I sort of feel like "one big default with multiple stitch options" is easier to maintain and might be easier for people to pick and choose symbols if we had more of a UI for it so I'd lean towards option 1.
In both these cases, though, changing the current symbol means iterating through the whole table and updating each entry. We could probably re-design to avoid this, but the current structure makes it pretty easy for people to override individual symbols and I think we want to keep that property. So probably just make a function that does the iterating to set the defaults and leave it at that?
Sorry, this got kind of long. But yes I would absolutely love to support Japanese symbols, and I guess don't be afraid to change how our legend works right now if it's going to make this easier to do?
from pyknit.
Hey! So I totally forgot to update that I did it!
Let me find a way to tag my pull request
from pyknit.
#49 So here is my pull request!
I created two separate stitch legends that can be fed into the chart creator - you choose which one to import and use in your notebook. That way both stitch types are able to be used in the code! I only put a few of the stitches I was using at the time, but there is alot more I will eventually update it with as I use the chart feature.
For consistency, I named the photos the same as the other stitches, just in a folder called /japanese - so they share the same directory, but the japanese symbols use + /japanese. This could possibly be leveraged to combine the stitch legends and include different types of symbols as a more advanced implementation!
I also heavily relied on the tutorial notebooks to understand how to use the program, and I really liked them, so I created one for the japanese charts. Please let me know if you have any questions or clarifications that I could make to the tutorial page to better help people use the feature!
from pyknit.
Also, python is not a language that I typically use, and I'm well aware that my implementation could use some 'sprucing' or 'organizing' (sorry java user here). Please pleeease feel free to do that to the code I wrote, just fill me in on what changes you made :)
from pyknit.
Related Issues (20)
- Add error handling for nonsensical gauge swatches.
- Add error handling for nonsensical sleeves and increases HOT 3
- Draw chart symbols correctly HOT 7
- 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?
- Estimate the time it would take to knit a pattern HOT 1
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.