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

Class ScarfPatternFactory

src/scarf_pattern_factory.ts:21–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19const FALSE_STRING = 'false';
20
21class ScarfPatternFactory {
22 static cubicBezierFocalPoints: CubicBezierFocalPoints = {
23 Balanced: [{x: 0.6, y: 0.3}, {x: 0.4, y: 0.7}],
24 Thin: [{x: 0.75, y: 0.3}, {x: 0.5, y: 0.7}],
25 Thick: [{x: 0.5, y: 0.3}, {x: 0.25, y: 0.7}],
26 Straight: [{x: 0.5, y: 0.5}, {x: 0.5, y: 0.5}],
27 };
28
29 factoryName = 'Sophie Scarf';
30
31 borderStitches: number = 3;
32 rowsInput: PatternFactoryInput;
33 centerLengthInput: PatternFactoryInput;
34 centerWidthInput: PatternFactoryInput;
35 textureInput: PatternFactoryInput;
36 shapeInput: PatternFactoryInput;
37 /**
38 * Whether the increases and decreases should be symmetric. If true, increases
39 * and decreases occur on even rows. If false, increases occur on even rows
40 * and decreases on odd rows.
41 */
42 symmetricInput: PatternFactoryInput;
43
44 constructor() {
45 this.rowsInput = new PatternFactoryInput(
46 'Total Length',
47 'How long should the scarf measure from tip to top along its ' +
48 'longest dimension?',
49 412, 'rows');
50 this.centerLengthInput = new PatternFactoryInput(
51 'Center Length',
52 'How many additional rows should the scarf have in the center part ' +
53 '(between increases and decreases) along the long dimension?',
54 0, 'rows');
55 this.centerWidthInput = new PatternFactoryInput(
56 'Center Width',
57 'How many stitches should the scarf have in the center part, ' +
58 'between the increases and decreases?' +
59 ' Does not include the 6 stitches for the i-cord border.',
60 25, 'stitches');
61 this.textureInput = new PatternFactoryInput(
62 'Texture', 'What type of texture do you want?',
63 Array.from(texturesMap.keys())[0] as string, null,
64 Array.from(texturesMap.keys()));
65 this.shapeInput = new PatternFactoryInput(
66 'Shape', 'What general shape would you like?',
67 Object.keys(ScarfPatternFactory.cubicBezierFocalPoints)[0] as string,
68 null, Object.keys(ScarfPatternFactory.cubicBezierFocalPoints));
69 this.symmetricInput = new PatternFactoryInput(
70 'Symmetric', 'Should the increases and decreases be symmetric?',
71 TRUE_STRING, null, [TRUE_STRING, FALSE_STRING]);
72 }
73
74 getInputs(): PatternFactoryInput[] {
75 return [
76 this.rowsInput, this.centerLengthInput, this.centerWidthInput,
77 this.textureInput, this.shapeInput, this.symmetricInput
78 ];

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected