Recently I wanted to knit a torus, but my old torus-knitting program was on my old computer, and enough things had changed in the world since the last time I used it that I couldn’t get it to compile, so today I rewrote it in JavaScript.

I’m putting it here so that I can find it when I’m looking for it again. Maybe you want to knit a torus? You can generate a pattern here, too! (If you are reading this in a feed-reader, you will need to click through to the page in order to generate your torus.)

Do note that I have not yet gotten around to putting in any error-checking, so if you tell the program that you want the hole in the middle to be bigger than the entire torus, it will oblige and generate a nonsensical pattern for you. Also note that this runs entirely as JavaScript in your browser, so putting stupid values into the form won’t do anything sneaky and will, at worst, make your browser irritated at you.

The outer radius is the distance from the middle of the hole to the edge of the entire torus. The inner radius is the distance from the middle of the hole to the edge of the hole. The gauge calculation is assuming that you have knit a 4-inch by 4-inch gauge swatch and that you have counted how many stitches and rows are in 4 inches. (Or that you are reading this value off the ball band of the yarn. This program does not judge.)

Outer radius (inches):
Inner radius (inches):
Number of stitches in 4 inches:
Number of rows in 4 inches: