MCPcopy Create free account
hub / github.com/alefore/knit / CablePatternFactory

Class CablePatternFactory

src/cable_pattern_factory.ts:261–329  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

259}
260
261class CablePatternFactory {
262 factoryName: string = 'Cables';
263
264 cableLengthInput: PatternFactoryInput;
265 cableCountInput: PatternFactoryInput;
266 rowsBetweenCablesInput: PatternFactoryInput;
267 cableEdgeRowsInput: PatternFactoryInput;
268 smoothingRowsInput: PatternFactoryInput;
269 innerCablesInput: PatternFactoryInput;
270 marginTypeInput: PatternFactoryInput;
271 marginDistanceInput: PatternFactoryInput;
272
273
274 constructor() {
275 this.cableLengthInput = new PatternFactoryInput(
276 'Cable Length', 'How long should the pattern be?', 1,
277 'cable pattern rows');
278 this.cableCountInput = new PatternFactoryInput(
279 'Cable Count', 'How many cables do you want?', 5, 'cables');
280 this.rowsBetweenCablesInput = new PatternFactoryInput(
281 'Rows Between Cables', 'How many rows between cables?', 2, 'rows');
282 this.cableEdgeRowsInput = new PatternFactoryInput(
283 'Cable edge rows', 'Length of the edge of each cable', 2, 'rows');
284 this.smoothingRowsInput = new PatternFactoryInput(
285 'Single-stitch jump rows',
286 'For how many rows should cables only jump a single stitch?', 1,
287 'rows');
288 this.innerCablesInput = new PatternFactoryInput(
289 'Inner Cables',
290 'Should we enable inner cables? These only works with few parameters.',
291 'Disable', null, ['Enable', 'Disable']);
292 this.marginTypeInput = new PatternFactoryInput(
293 'Margin Type', 'Type of margin to use.', 'None', null,
294 ['None', 'ICord', 'Knit']);
295 this.marginDistanceInput = new PatternFactoryInput(
296 'Margin Distance',
297 'Number of purl stitches between the cable and its margin.', 2,
298 'stitches');
299 }
300
301 getInputs(): PatternFactoryInput[] {
302 return [
303 this.cableLengthInput,
304 this.cableCountInput,
305 this.rowsBetweenCablesInput,
306 this.cableEdgeRowsInput,
307 this.smoothingRowsInput,
308 this.innerCablesInput,
309 this.marginTypeInput,
310 this.marginDistanceInput,
311 ];
312 }
313
314 build(): Pattern {
315 const output = new Pattern();
316 const marginType = this.marginTypeInput.value();
317 const marginDistance =
318 marginType == 'None' ? 0 : this.marginDistanceInput.numberValue();

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected