liveknit

A prototype interface for working live with algorithmic knitting patterns, via the AYAB (all yarns are beautiful) hardware hack of Brother knitting machines.

Return to liveknit

Minimal instructions

A pattern is defined as a simple javascript function in one of two forms; either row(row) to calculate a row at a time from a given row number, or needle(needle, row) to calculate a needle postiion at a time based on needle number and row number. For example:

const needle = (needle, row) => (needle ^ row) % 3;

Or to define a function for calculating a row at a time, you could do:

function row(row) {
  const result = [];
  for (let i = 0; i < 200; ++i) {
    result.push(Math.round(Math.random()));
  }
  return(result);
}

Which would be the same as doing:

function needle(needle, row) {
  return Math.round(Math.random())
}
    

Both row and needle functions also accept a third 'history' argument that is a function for reading previous rows. E.g. history(1, needle) repeats the previous row, and history(1, needle+1) shifts it one needle. So the following will take the previous row (so you must already have knitted or simulated at least one row), and progressively shift it to the left.

function needle(needle, row, history) {
  return history(1, needle+1);
}
    

liveknit supports collaborative patterning, just share the URL with a friend. Edits to the code and 'update' evaluations are shared. Other interactions, like progressing to the next row by knitting or pressing 'simulate', are not.

Free/open source software

(c) Alex McLean and contributors 2026, released under the Affero GNU Public License, v3.0 or later.

source