Wyrm Beans

Wyrm Beans

Do you ever look at knitted items and liken them to dragon scales? - I do. So when I decided to make generative textured hats it made sense to call them Wyrm Beans.

Just as we can have generative pixel colors on a screen, we can have generative textures in a hat. We can use the power of randomness to create lacy patterns. Knitting is really just executing code.

If you knit, patterns are at wyrmbean.com. There you will be able to randomize and download a knitting pattern. Knit at your own risk - these patterns are experimental. I'd love to see pictures if you make one.

This is a project I've been working on while in a batch at the Recurse Center (RC).

Below are some of the knitty-gritty details (pun intended).

Test Beans:

The first (plum) needed some editing to make the pattern more general. The second 2 worked well without edits.

The Code

The prototype and testing was all done in p5js. I experimented with putting the pattern in Elm (with pairing at RC) and then I ended up putting the final page in Svelte to start learning the framework and TypeScript. I found Svelte and TypeScript to be quite pleasant to work with. I have a lot to learn.

Example Pattern

The Algorithm

First there were some assumptions:

  • This is for a small-medium hat
  • 3.5mm then 4mm needles
  • Worsted weight yarn (220yds)
  • Hats will have repeating panels with repeating patterns.
  • The stitches to use:
    • Knit and Purl
    • Increase: yarn over (yo)
    • Increase: make 1 left (m1l) - leans left
    • Increase: make 1 right (m1r) - leans right
    • Decrease: slip-slip-knit (ssk) - leans left
    • Decrease: knit 2 together (k2tog) - leans right
    • Double decrease: slip 2, knit 1, pass 2(s2kp2) - centered
    • (the final code includes a knit-purl only option as well)
  • The construction will be made from ribbing, Chart A and Chart B
  • The knitter(inputs) can decide on the stitches available and 4, 5, or 6 panels.
  • The top of the hat will close the same for all hats with {ssk, k, k} and then with an embroidery needle for the last 6-8 stitches.
A hat with labels for ribbing at the base, chart A that repeats for the main part an part B for the closing.

The pattern (Chart A)

For this lace pattern there is the same number of stitches per row. Therefore increases and decreases have to come in pairs.

To make chart A:

  • Make a list that is the width of the panel
  • Randomly set the number of pairs of increase/decrease stitches
  • Randomly decide the types of increase and decrease stitches.
  • Make the rest of the stitches knit stitches.
  • Randomly decide if there will be 6 or 8 rows in Chart A
  • Make the pattern by shuffling the list of stitches and adding a knit-only row between each shuffle until the Chart A has the right number of rows

Example Chart A:

The pattern (Chart B)

Chart B decreases by using S2kp2 once each row and then twice as it gets toward the top. Before the last few rows there is a randomized pair of increase and decrease stitches. After Chart B there is the same closing pattern for all hats. to cinch it.

What I learned and other thoughts

  • The patterns worked! I was ready to have some dull or topologically challenged hats, but they came out similar to how I had hypothesized.
  • When hats have more stitches that lean one way the hat spirals beautifully
  • Going from p5.js to TypeScript in Svelte was pretty fun and I am going to try another project in this framework.
    • Tailwind was one of the hardest parts - I have been mostly using CSS in its own file. I need to build my skills here.
  • While coding these hats I thought about making a hat with the binary (knit/purl) "I am a potato" over and over again.
  • Budgies like yarn - Lift was a little territorial with the wyrm beans:
A green budgie sitting on a plum hat on a table.

Want to become a better programmer? Join the Recurse Center!