1
0
Fork 0

🐛 Fixed incorrect handling of percentage option when sampling

This commit is contained in:
Joost De Cock 2018-09-06 16:48:36 +02:00
parent 691220aaa8
commit fecee2479e

View file

@ -111,14 +111,16 @@ Pattern.prototype.sampleParts = function() {
*/ */
Pattern.prototype.sampleOption = function(optionName) { Pattern.prototype.sampleOption = function(optionName) {
let step, val; let step, val;
let factor = 1;
let anchors = {}; let anchors = {};
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"; throw "Cannot sample an option without min and max values";
} }
val = option.min; if (typeof option.pct !== "undefined") factor = 100;
step = (option.max - val) / 9; val = option.min / factor;
step = (option.max / factor - val) / 9;
for (let l = 1; l < 11; l++) { for (let l = 1; l < 11; l++) {
this.options[optionName] = val; this.options[optionName] = val;
this.debug( this.debug(