Skip to content

Commit 506081e

Browse files
Laura DevendorfLaura Devendorf
Laura Devendorf
authored and
Laura Devendorf
committed
added frameloom functions
1 parent e75d113 commit 506081e

File tree

2 files changed

+99
-3
lines changed

2 files changed

+99
-3
lines changed

src/app/core/model/draft.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,7 @@ export class Draft{
969969
* @param i: the tieups array, j: the treadling array, the threading array
970970
* @returns (nothing) in the future - this can return the specific points to update on the draft
971971
*/
972-
recalculateDraft(tieup, treadling, threading) {
972+
recalculateDraft(tieup: Array<Array<boolean>>, treadling: Array<number>, threading: Array<number>) {
973973
for (var i = 0; i < treadling.length;i++) {
974974
var active_treadle = treadling[i];
975975
if (active_treadle != -1) {

src/app/mixer/provider/operation.service.ts

+98-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import { D } from '@angular/cdk/keycodes';
1+
import { D, E } from '@angular/cdk/keycodes';
22
import { Injectable, Input } from '@angular/core';
33
import { Cell } from '../../core/model/cell';
44
import { Draft } from "../../core/model/draft";
55
import { VaeService} from "../../core/provider/vae.service"
66
import { PatternfinderService} from "../../core/provider/patternfinder.service"
77
import utilInstance from '../../core/model/util';
88
import { Loom } from '../../core/model/loom';
9+
import { input } from '@tensorflow/tfjs-layers';
10+
import { findIndex } from 'lodash';
911

1012
export interface OperationParams {
1113
name: string,
@@ -1620,7 +1622,93 @@ export class OperationService {
16201622
})
16211623
)
16221624
}
1623-
}
1625+
}
1626+
1627+
1628+
const makeloom: Operation = {
1629+
name: 'floor loom',
1630+
dx: 'uses the input draft as drawdown and generates a threading, tieup and treadling pattern',
1631+
params: [
1632+
1633+
],
1634+
max_inputs: 1,
1635+
perform: (inputs: Array<Draft>, input_params: Array<number>) => {
1636+
if(inputs.length === 0) return Promise.resolve([]);
1637+
1638+
const l:Loom = new Loom(inputs[0], 8, 10);
1639+
l.recomputeLoom(inputs[0]);
1640+
1641+
const threading: Draft = new Draft({warps: inputs[0].warps, wefts: l.num_frames});
1642+
threading.name = "threading_"+inputs[0].name;
1643+
1644+
l.threading.forEach((frame, j) =>{
1645+
console.log("looping", frame, j)
1646+
if(frame !== -1) threading.pattern[frame][j].setHeddle(true);
1647+
});
1648+
1649+
const treadling: Draft = new Draft({warps:l.num_treadles, wefts: inputs[0].wefts});
1650+
console.log(treadling);
1651+
l.treadling.forEach((treadle_num, i) =>{
1652+
if(treadle_num !== -1) treadling.pattern[i][treadle_num].setHeddle(true);
1653+
});
1654+
treadling.name = "treadling_"+inputs[0].name;
1655+
1656+
const tieup: Draft = new Draft({warps: l.num_treadles, wefts: l.num_frames});
1657+
l.tieup.forEach((row, i) => {
1658+
row.forEach((val, j) => {
1659+
tieup.pattern[i][j].setHeddle(val);
1660+
})
1661+
});
1662+
tieup.name = "tieup_"+inputs[0].name;
1663+
1664+
1665+
return Promise.resolve([threading, tieup, treadling]);
1666+
1667+
}
1668+
1669+
1670+
1671+
1672+
}
1673+
1674+
const drawdown: Operation = {
1675+
name: 'drawdown',
1676+
dx: 'create a drawdown from the input drafts (order 1. threading, 2. tieup, 3.treadling)',
1677+
params: [
1678+
1679+
],
1680+
max_inputs: 3,
1681+
perform: (inputs: Array<Draft>, input_params: Array<number>) => {
1682+
if(inputs.length < 3) return Promise.resolve([]);
1683+
1684+
1685+
const threading: Array<number> = [];
1686+
for(let j = 0; j < inputs[0].warps; j++){
1687+
const col: Array<Cell> = inputs[0].pattern.reduce((acc, row, ndx) => {
1688+
acc[ndx] = row[j];
1689+
return acc;
1690+
}, []);
1691+
1692+
threading[j] = col.findIndex(cell => cell.getHeddle());
1693+
1694+
}
1695+
1696+
const treadling: Array<number> = inputs[2].pattern
1697+
.map(row => row.findIndex(cell => cell.getHeddle()));
1698+
1699+
const tieup = inputs[1].pattern.map(row => {
1700+
return row.map(cell => cell.getHeddle());
1701+
});
1702+
1703+
const drawdown: Draft = new Draft({warps: inputs[0].warps, wefts: inputs[2].wefts});
1704+
drawdown.recalculateDraft(tieup, treadling, threading);
1705+
return Promise.resolve([drawdown]);
1706+
1707+
}
1708+
1709+
1710+
1711+
}
16241712

16251713

16261714

@@ -1663,6 +1751,8 @@ export class OperationService {
16631751
this.ops.push(variants);
16641752
this.ops.push(knockout);
16651753
this.ops.push(crop);
1754+
this.ops.push(makeloom);
1755+
this.ops.push(drawdown);
16661756

16671757

16681758
//** Give it a classification here */
@@ -1692,6 +1782,12 @@ export class OperationService {
16921782
ops: [germanify, crackleify]}
16931783
);
16941784

1785+
1786+
this.classification.push(
1787+
{category: 'frame loom support',
1788+
ops: [makeloom, drawdown]}
1789+
);
1790+
16951791
}
16961792

16971793

0 commit comments

Comments
 (0)