Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: Browser-based knitting (pattern) software (github.com/alefore)
135 points by afc 5 months ago | hide | past | favorite | 29 comments
I wrote some simple open source web-based app to (1) dynamically compute knitting patterns (based on input parameters, such as the exact desired size), and (2) display these patterns and help me keep track of which row I'm on (as I start knitting), similar to minimalist "row counters" that other knitters use. It also gives you a simple visualization of the shape of what you're knitting. You can see it in action at https://alefore.github.io/knit/ (and read about it in https://github.com/alefore/knit).

Right now I only implemented on simple pattern: Sophie scarfs. After knitting one that came out somewhat … asymmetric, I decided to just write some software to help me (1) easily adjust the length/width of the scarf (using Bézier curves), and (2) keep track of which row I'm on (so that I can make sure I apply increases/decreases at the right places). In the future, I expect to extend this with many other knitting patterns for other types of items.

The application is 100% browser (JavaScript, tested in only in Chrome in Linux/Android) based (no server-side component): all state is kept in the URL hash. I've used it to knit two scarves, including https://github.com/alefore/knit/blob/main/images/000.jpg.

The current state of knitting patterns is far from optional, stuck in pre-computer times. Perhaps knitters are not the most technically minded group. Most knitters just download patterns as PDF files. These files will show multiple numbers from which you should choose one depending on the size you're knitting, saying things like "Purl 24 (32 38 42 50 64) times" (you're supposed to pick the right number depending on the size you're knitting). They'll say things like "repeat rows 4 to 6 sixteen times".

I think software can display patterns much better (including not being limited to a few pre-selected sizes, but letting you choose the _exact_ size you want, and adjusting everything accordingly), and keep track of your progress much more easily. For example, for my scarf, the user inputs the desired number of rows (based on the desired length, which makes the pattern agnostic to the needle size), and the software computes where to apply increases/decreases.

I have many other ideas for improvements (e.g., track how much time I've spent in each row, show a clock), but I figured I'd share this early and ask for feedback. Hopefully there are other fellow knitters in HN. :-) Check it out and let me know what you think!




I started learning to knit last fall and I have been really enjoying it.

If you're a software engineer, I think it scratches a lot of itches:

1. Knitting patterns are sort of like a tiny little programming language, with loops (as in iteration, not as in, uh, loops of yarn) and choice.

2. Knitting charts are a lot like pixel art.

3. There is a very fine-grained skill progression where you can ease your way in by starting with simple patterns that only use a few techniques. But there is always a next level of skill and challenge. The lore is incredibly deep and there is a ton to learn. You'll never run out of ways to improve your expertise. At the same time, even as a beginner, you can make objects that are useful and beautiful.

4. If you're tired of staring at a screen and crave something tactile, it is an excellent counter-point. It's extremely tactile, hands-on, and texture-oriented. It just feels good to knit or play with yarn and textiles. There are so many rich colors and color combinations at a level of vibrance that a screen never attains.

5. If you're mentally tired at the end of the day but still want to feel like you're making progress on something meaningful instead of just scrolling on your phone, you can always pick up a project and knit a few more rows without needing a lot of brainpower. At the same time, you can also choose projects with enough complexity that it doesn't feel totally mindless like a coloring book or something.

6. Unlike software where much of our output is intangible and meaningless to the world, everyone can see and appreciate knitted objects. The things you make are instantly beloved and appreciated.

7. If you are introverted and prone to anxiety, knitting is a very nice therepeutic escape.

I highly recommend it.


Point 4 is what resonates with me, and first got me into knitting. So much of what I do is in front of a screen, and creating a real, physical object and having something to occupy my hands lets me step away from the computer and work relatively mindlessly.


Wow, this is exactly how I feel! I'm a software engineer and I also started knitting last year. I'm really enjoying it for all the reasons you listed.


This is great! I'm also a knitter, and I really like putting together little programs to help me design or write out patterns. My favourite so far has been an Elixir Livebook notebook I made to design a scarf for my partner. It outputs row counts and an image of what the end result will look like: https://put.bo0tzz.me/s/30iu0n2k.png The (messy) livebook code is here for whoever is interested: https://gist.github.com/bo0tzz/eb7818f7db3542ec540965252a344...

Another program I made (and unfortunately lost) was one to generate bespoke sock sizings (and corresponding pattern instructions) from measurements I put in.


Nice idea. I love how you manage to show the shapes of the design. But how do you know the size of the finished object? I assume you ask knitters to do the calculations themselves. That can be difficult (for me it was until I put words on it).

Being a long time knitter and also a designer (not a professional designer, but just someone that likes to design her own patterns and doesn't like to follow other patterns), I did several knitting tools using LibreOffice Calc (may be you can call that "old school"), you can download them here: https://www.aiguilles-magiques.com/-Outilsde-creation-?lang=... Sorry but they are mainly in French. Well, the sweater calculator is in English too.

For these tools, I just ask the knitter to enter the gauge and, yes, all the necessary measurements. The sheets make all the maths. Obviously there are way perfectible, and they don't show the shape of the finished as you did for your tool (notice the picture on y tools were made with Inkscape).

All this tools are under licence CC by-sa.


As a fellow knitter, this is pretty neat--I really like the notation. I mostly make hats, and do most of my pattern work using a pixel art app and a piece of paper for notation.

Any interest in expanding the scope of this to include other designs? Double knitting? PRs welcome?


I absolutely intend to expand the scope to include other designs.

I happen to be knitting a double-knitting blanket right now, my first double-knitted project, haha. I was actually thinking yesterday that it would be super neat if we could just feed it a black-and-white image and have it generate the rows. ... just haven gotten around to it.

But, yeah, if you look at the implementation, you'll see that everything is fairly generic, and the only parts specific to sophie scarfs are contained in a single file: https://github.com/alefore/knit/blob/main/scarf_pattern_fact...

That said, I expect the pattern class will need some improvements to be able to accomodate double-knitting (e.g., for visualization and such).


I’d love this for crochet.


Not a generator but I love this crochet simulator! https://github.com/timhutton/crochet-simulator


While your point about knitting patterns being largely unchanged by computers is true, there are a few very good software-enabled knitting tools out there:

- KnitCompanion is a complex but extremely powerful app to take PDF patterns and turn them into very efficient, effective digital patterns. You can designate specific steps, walk through steps and charts with voice control, extensively reformat a pattern, etc. I use this for all moderately complex knitting.

- TinCanKnits is a pair of pattern designers who have recently released an app for their own patterns that customizes the pattern (showing only your size, changing chart colors to match your yarn, etc.)

- CustomFit by Amy Herzog is a tool with a collection of sweater designs that can be fully customized to your own gauge, measurements, design preferences, etc.

- There are a number of calculators out there for sock knitting (how many stitches/rows for heel flap, gusset calculations, etc.).


Another HNer and I have created an app for knitting and crochet, with customisable counters, pattern import in many format, possibility to annotate, draw on pattern... as well as other knitting & crochet tools (chart creator, unit converters, glossaries, swatch adaptor...). If you want to give it a try, your feedbacks are very much welcomed, especially as you are already using an app for knitting. https://rowcounterapp.com/


This looks very nice! I'm definitely going to give it a try--thanks for mentioning it


A while ago I started to build something similar, but I didn't get much farther than choosing a name for the project (https://github.com/mk12/loopy). I want to design a language that can specify patterns precisely and unambiguously, and then visualize them in a physically accurate way. For basic 2D patterns I was thinking I could render each stitch based on it and its neighbors (3x3 grid of K/P). But that wouldn't be that useful. What would really be neat is to use a physics engine to simulate the yarn in 3D. For example the simulations would show stockinette curling and ribbing stretching without that being hardcoded anywhere. But I think it's too hard and I have no idea where to start with that.


This looks intriguing! One thing I'd like to ask is to increase the button and overall font size since it looks a little bit tiny on mobile, which might be the platform people use when they don't knit in front of their monitors.


Good point. I'll look into that. Thank you for the feedback.

(You can swipe left/right to change rows on mobile; though your suggestion still stands. Just mentioning it in case it helps.)


> "Purl 24 (32 38 42 50 64) times"

Syntax like this is probably why wartime censors disapproved of mailing knitting patterns.

EDIT: someone needs to write a short story procedural in which the plaintext turns out to be a knitting pattern.


As an avid crocheter I'm not sure what's wrong with that syntax. How else would one communicate the same information inline?


It's not a matter of communicating the knitting information, it's what other information[0,1] may be communicated at the same time.

Supposing we suspect this pattern to be a coded message[2], let's take our given (data) and strip out the stop words:

24 32 38 42 50 64

if these were straight ASCII values, we'd decode to '\x18 &*2@', which maybe means something under a whitening transform, but we have a big clue that we ought to look elsewhere: in real, uniguous, knitting patterns, the number of stitches has to continually increase[3,4].

That suggests we should look at the differences[5,6] between the values:

8 6 4 8 4

and of course we'd want to take the entire "knitting pattern" into account when guessing[7,8] how to interpret this, but just for didactic purposes let's say in one potential decode we threshold at n=5, assigning 0 to high and 1 to low, and interpret the result in ITA-2[9](why?): we get 00101, decoding to 'S'.

That may seem like a lot of work to get one character, but we're no longer in an age when "01 if by land, 10 if by sea"[A] will go unnoticed, and the technology is dual-use: the same tricks used by a spy to push messages through below the noise floor can also be used by a space probe, to communicate during one's Voyage.

Lagniappe: even if you're not sending coded messages to someone halfway around the world with knitting (or fibre arts[B] in general, or...), they're an excellent way, during meetings that could've been emails, to get something productive done.

[0] https://en.wikipedia.org/wiki/Covert_channel

[1] compare essence and accident in philosophy; how far back can we push the notion that essence communicates zero bits and accidents communicate some positive (rational) number of bits? Compare https://en.wikipedia.org/wiki/Succinct_data_structure

[2] eg, if you are sending text which looks like english gobbeldygook with idiosyncratic capitalisation conventions, and all sentences are 13 words long, it would look as suspiciously framed as if a message consisted entirely of 5 word sentences.

[3] Exercises: why do animal calls (whalesong, birdsong, etc.) often ramp in frequency? (1 pt) what was the chinese notion of the language of the birds, and how does it relate to other spoken languages? (essay, 5 pts)

[4] that's to first order; we could get fancier with second and higher order analyses to see if our putative knitting pattern has any hope of creating a closed physical object, etc.

[5] God made Nat, all else is the work of People?

[6] from here we can go into calculus, but that's a different topic...

[7] early digital computers were built for ballistics, cryptanalysis, and explosive simulation. Despite all the bossware, we should be proud that we've managed to find other uses for them in the eight decades since.

[8] it really helps when guessing to have a known plaintext; Körner has some interesting stories about how the teutonic tendency to Ordnung muß sein helped the allies during WWII. Eg. most military comms won't decrypt to "new phone who dis?".

[9] https://en.wikipedia.org/wiki/Baudot_code Exercise: which coded messages decode to the same glyphs in ITA2 and MTK-2? (example: 1 pt, full set: 2 pts, do either of these relate to keyboard layout? 0 pts)

[A] do crochet and knitting also differ by number of needles?

[B] compare https://en.wikipedia.org/wiki/Quipu


A character in Neal Stephenson's Baroque Cycle encrypts messages in (IIRC) embroidery.


My wife will be happy with this.


Would love to hear if it works for her, or if she has any feedback.


Absolutely! Will let you know.


Nice! Friend of mine loves knitting!

But in the example in your Github, was does "2K KFB 6K WYIF 3SLP" mean? The explanation is "The rest are the steps for this row.". I don't understand. Can somebody explain?


Your friend will likely be familiar with this notation, which is fairly standard (though not by any means universal). I think it means: knit 2 stitches, then knit the next stitch twice (incrementing the number in that row as result); knit 6 more then slip the last 3 stitches while holding the yarn in front.


Thank you!

Mouse over each abbreviation and you should see a tooltip. This specific row would mean "2 knit, Knit Front Back, 6 knit, with yarn in front 3 slip."

This may also help: https://en.wikipedia.org/wiki/Knitting_abbreviations


These are generally written as k2, k6, etc. -- is there a reason why you reversed them?


Oh, good point, I might swap them. I think you're right.

I sometimes print something like "8(K P)" where I think putting the number in front makes more sense. But yeah, I think if there are no parentheses, I should just print it as you suggest.

Thank you!


OK, I've adjusted the output accordingly (https://github.com/alefore/knit/commit/b08f1d1957acf7b37c2cf...).


I love HN for such projects. Thank you!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: