✨ Added sampling of static options
This commit is contained in:
parent
829baa469b
commit
164c40c695
2 changed files with 3 additions and 2 deletions
|
@ -147,7 +147,9 @@ Pattern.prototype.sampleOption = function(optionName) {
|
||||||
let parts = this.sampleParts();
|
let parts = this.sampleParts();
|
||||||
let option = this.config.options[optionName];
|
let option = this.config.options[optionName];
|
||||||
if (typeof option.min === "undefined" || typeof option.max === "undefined") {
|
if (typeof option.min === "undefined" || typeof option.max === "undefined") {
|
||||||
throw "Cannot sample an option without min and max values";
|
let min = option * 0.9;
|
||||||
|
let max = option * 1.1;
|
||||||
|
option = { min, max };
|
||||||
}
|
}
|
||||||
if (typeof option.pct !== "undefined") factor = 100;
|
if (typeof option.pct !== "undefined") factor = 100;
|
||||||
val = option.min / factor;
|
val = option.min / factor;
|
||||||
|
|
|
@ -98,7 +98,6 @@ it("Should sample an option", () => {
|
||||||
pattern.sample();
|
pattern.sample();
|
||||||
expect(pattern.parts.a.paths.test_1.render).to.equal(true);
|
expect(pattern.parts.a.paths.test_1.render).to.equal(true);
|
||||||
expect(pattern.parts.b.paths.test_10.ops[1].to.y).to.equal(10);
|
expect(pattern.parts.b.paths.test_10.ops[1].to.y).to.equal(10);
|
||||||
expect(() => pattern.sampleOption("bonus")).to.throw();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should sample a measurement", () => {
|
it("Should sample a measurement", () => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue