Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Remapping gauge #2

Open
vid8687 opened this issue Feb 28, 2018 · 1 comment
Open

[Feature] Remapping gauge #2

vid8687 opened this issue Feb 28, 2018 · 1 comment

Comments

@vid8687
Copy link
Contributor

vid8687 commented Feb 28, 2018

Add support for remapping needle numbers to chosen gauges (full and half, possibly other a/b gauges)

@ixchow
Copy link
Member

ixchow commented Feb 28, 2018

Possible interface:

let k = new knitout.Writer();
//right now, k.mapper === null, which implies full gauge
k.knit('+', 'f' + 7, '6'); //knits on needle f7
k.setMapper(new knitout.HalfGaugeMapper());
k.knit('+', 'f' + 7, '6'); //knits on needle f17
k.unmappedKnit('+', 'f' + 7, '6'); //knits on needle f7

Where a Mapper is an object with two functions:

function MyMapper() { }
MyMapper.prototype.toMachine(bed, needle) {
    return {bed:bed, needle:needle*2};
}
//We could probably eliminate this one, but it turns out to be useful in certain cases:
MyMapper.prototype.fromMachine(bed, needle) {
    return {bed:bed, needle:needle/2};
}

This is not the only possible interface. For instance, a 'Mapper' could be an object that takes a knitout.Writer and proxies calls to it:

let k = new knitout.Writer();
let k2 = new knitout.HalfGaugeMapper({writer:k});
k.knit('+', 'f' + 7, '6'); //knits on needle f7
k2.knit('+', 'f' + 7, '6'); //knits on needle f17

Open questions:

  • how do we deal with mapping in the context of querying active needles on the machine? (I.e. if mapping is enabled, do we report actual machine locations that are occupied, or the needles that map to them?)
  • how do we handle switching gauges?
  • how do we support user mappers?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants