1.0.3 • Published 3 years ago

knitout v1.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
3 years ago

knitout-frontend-js

A javascript wrapper for all operations supported by knitout with basic error and type checking.

Very simple example rectangle:

const knitout = require('knitout');
let k = new knitout.Writer({carriers:["A", "B", "C"]});

k.in("B");

for (let n = 10; n >= 0; n -= 2) k.tuck("-", "f" + n, "B");

for (let n = 1; n <= 9; n += 2) k.tuck("+", "f" + n, "B");

for (let r = 0; r < 10; ++r) {
	for (let n = 10; n >= 0; --n) k.knit("-", "f" + n, "B");
	for (let n = 0; n <= 10; ++n) k.knit("+", "f" + n, "B");
}

k.out("B");

k.write("out.k"); //write to file
k.write(); //print to console

When you create a Writer you are required to supply a "carriers" list in the options.

In the table below:

  • carriers specify the yarn-carriers in use. These are specified as a string or an Array of strings. Multiple yarn carriers can be used to make one stitch ("plating").

  • direction specifies the direction in which the operation is performed. Legal values include "+" indicating increasing needle number direction or "-" indicating decreasing needle number direction.

  • bed+needle is an alpha-numeric value that specifies the bed and needle number. Legal values for bed are (f)ront, (b)ack, (f)ront(s)lider, (b)ack(s)lider. Needle is a Number value within the range supported by the machine. "fs10", for example, specifies front-bed slider location 10, "b20" specifies back-bed needle 20. The front-end also allows specifying bed needles as {bed:"f", needle:5}, ["f",5], or as "f", 5.

All knitout opcodes are supported as a front-end function. Currently, the frontend supports:

FunctionArgumentsExampleDescription
addHeadername(String),value(String)addHeader('Machine', 'SWGXYZ')Add header information as name,value pairs.
incarriersin("5")Bring in yarn carriers
inhookcarriersinhook("B")Bring in yarn carriers using the yarn inserting hook
releasehookcarriersreleasehook("5")Release the yarn inserting hook used to bring in the given yarn carriers
outcarriersout("6")Take out yarn carrier
outhookcarriersouthook("5")Take out yarn carrier with yarn inserting hook
stitchbefore(Number) after(Number)stitch(25,40)Before forming the loop, pull needle by before machine units, after forming the loop by after machine units. Not well-supported by the back-end currently.
stitchNumberindex(Number)stitchNumber(5)Explicit function for using stitch number extension that reads stitch values at index from a table. See extensions for details.
fabricPressermode(String)fabricPresser('auto')Explicit function for using fabric presser extension. Valid modes include 'auto', 'on', 'off'. See extensions for details.
rackrack value(Number)rack(1)Translate the back bed relative to the front bed by rack value needle units. Fractional values are legal and may be supported by the machine.
tuckdirection,bed+needle,carrierstuck("+","f10","B")Tuck on bed at needle using carriers in direction direction.
knitdirection,bed+needle,carriersknit("+","f10","B")Knit on bed at needle using carriers in direction direction.
xferfrom bed+needle,to bed+needlexfer("f10","b10")Transfer loops from from bed at needle to to bed at needle.
missdirection,bed+needle,carriersmiss("+","f10","B")Miss on bed at needle using carriers in direction direction i.e., perform carrier motion without knitting
splitdirection,from bed+needle,to bed+needle, carrierssplit("+","f10", "b10", "B")Pull a loop from from bed+needle and transfer old loops to to bed+needle in direction using carriers.
dropbed+needledrop("f10")Drop loops from bed+needle.
amissbed+needleamiss("f10")Tuck operation at bed+needle without using yarn.
pauseNonepause()Pause machine when instruction is encountered
commentStringcomment("This is a \n multi-line comment")Insert comments into knitout file
addRawOperationStringaddRawOperation("your knitout inst string")Escape hatch to directly inject knitout code

See knitout specification for further details.

See hello_world.js and sample.js for example usage. See carriers.js for additional carrier examples.

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

5 years ago

1.0.0

5 years ago