Created
April 30, 2019 04:58
-
-
Save aman-tiwari/cceb619f1c30b9efc12068a78ac9d16f to your computer and use it in GitHub Desktop.
beanie
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const carrier = '3'; | |
const alt = '6' | |
const w = Math.ceil(15 * 12) | |
const h = Math.ceil(15 * 21) | |
const side_toob_width = 4; | |
const cast_off_h = side_toob_width; | |
//import the knitout writer code and instantiate it as an object | |
var knitout = require ('../knitout-frontend-js/knitout'); | |
k = new knitout.Writer({carriers:['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']}); | |
// add some headers relevant to this job | |
k.addHeader('Machine','SWGXYZ'); | |
k.addHeader('Gauge','15'); | |
k.inhook(carrier); | |
let min = 1; | |
let max = min + w - 1; | |
for(let n = max; n >= min; --n) { | |
if((max - n) % 2 === 0) { | |
k.tuck('-', 'f' + n, carrier) | |
} | |
} | |
for(let n = min; n <= max; ++n) { | |
if((max - n) % 2 === 1) { | |
k.tuck('+', 'b' + n, carrier) | |
} | |
} | |
for(let n = max; n >= min; --n) { | |
if((max - n) % 2 === 1) { | |
k.tuck('-', 'f' + n, carrier) | |
} | |
} | |
for(let n = min; n <= max; ++n) { | |
if((max - n) % 2 === 0) { | |
k.tuck('+', 'b' + n, carrier) | |
} | |
} | |
// toob | |
let side_tube_start = min + side_toob_width; | |
let side_tube_end = max - side_toob_width; | |
for(let rows = 0; rows < 2; rows++) { | |
for(let n = max; n >= min; --n) { | |
const bed = n < side_tube_start || n > side_tube_end ? 'b' : 'f' | |
if(n == max && rows == 0) continue; | |
k.knit('-', bed+n, carrier); | |
} | |
for(let n = min; n <= max; ++n) { | |
const bed = n < side_tube_start || n > side_tube_end ? 'f' : 'b' | |
k.knit('+', bed+n, carrier); | |
} | |
if(rows == 0) { | |
k.releasehook(carrier); | |
} | |
} | |
k.inhook(alt) | |
k.tuck('-', 'f' + (max + 1), alt) | |
for(let rows = 0; rows < h; rows++) { | |
const curr_carrier = Math.floor(rows / 2) % 2 == 0 ? alt : carrier; | |
for(let n = max; n >= min; --n) { | |
const bed = n < side_tube_start || n > side_tube_end ? 'b' : 'f' | |
if(n == max && rows == 0) continue; | |
k.knit('-', bed+n, curr_carrier); | |
} | |
for(let n = min; n <= max; ++n) { | |
const bed = n < side_tube_start || n > side_tube_end ? 'f' : 'b' | |
k.knit('+', bed+n, curr_carrier); | |
} | |
if(rows == 0) { | |
k.releasehook(alt) | |
k.drop('f' + (max + 1)) | |
} | |
} | |
for(let rows = 0; rows < 2; rows++) { | |
for(let n = side_tube_end; n >= side_tube_start; --n) { | |
const bed = n % 2 == 0 ? 'b' : 'f' | |
k.knit('-', bed + n, carrier) | |
} | |
for(let n = side_tube_start; n <= side_tube_end; ++n) { | |
const bed = n % 2 == 1 ? 'b' : 'f' | |
k.knit('+', bed + n, carrier) | |
} | |
} | |
for(let n = max; n > side_tube_end; --n) { | |
k.drop('b' + n) | |
k.drop('f' + n) | |
} | |
for(let n = min; n < side_tube_start; ++n) { | |
k.drop('b' + n) | |
k.drop('f' + n) | |
} | |
for(let rows = 0; rows < cast_off_h; rows++) { | |
for(let n = side_tube_end; n >= side_tube_start; --n) { | |
k.knit('-', 'b'+n, carrier); | |
} | |
for(let n = side_tube_start; n <= side_tube_end; ++n) { | |
k.knit('+', 'f'+n, carrier); | |
} | |
} | |
for(let rows = 0; rows < 2; rows++) { | |
for(let n = side_tube_end; n >= side_tube_start; --n) { | |
const bed = n % 2 == 0 ? 'b' : 'f' | |
k.knit('-', bed + n, carrier) | |
} | |
for(let n = side_tube_start; n <= side_tube_end; ++n) { | |
const bed = n % 2 == 1 ? 'b' : 'f' | |
k.knit('+', bed + n, carrier) | |
} | |
} | |
// TODO: cast off | |
//k.xfer("f0","b0"); | |
//k.xfer("f1","bs1"); | |
//k.xfer("f2","b2"); | |
//k.xfer("f3","bs3"); | |
k.outhook(carrier); | |
k.outhook(alt) | |
k.write('toob.k'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment