From fecee2479eaaf401e1665e88bbf69430af0fd857 Mon Sep 17 00:00:00 2001 From: Joost De Cock Date: Thu, 6 Sep 2018 16:48:36 +0200 Subject: [PATCH] :bug: Fixed incorrect handling of percentage option when sampling --- src/pattern.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pattern.js b/src/pattern.js index dabc071d89d..859685c2e4f 100644 --- a/src/pattern.js +++ b/src/pattern.js @@ -111,14 +111,16 @@ Pattern.prototype.sampleParts = function() { */ Pattern.prototype.sampleOption = function(optionName) { let step, val; + let factor = 1; let anchors = {}; let parts = this.sampleParts(); let option = this.config.options[optionName]; if (typeof option.min === "undefined" || typeof option.max === "undefined") { throw "Cannot sample an option without min and max values"; } - val = option.min; - step = (option.max - val) / 9; + if (typeof option.pct !== "undefined") factor = 100; + val = option.min / factor; + step = (option.max / factor - val) / 9; for (let l = 1; l < 11; l++) { this.options[optionName] = val; this.debug(