1
0
Fork 0

Added support for different option types

This commit is contained in:
Joost De Cock 2018-09-03 12:20:51 +02:00
parent 2d0f48bfc6
commit ade70da54b
2 changed files with 46 additions and 7 deletions

View file

@ -39,12 +39,13 @@ export default function Pattern(config = false) {
for (let i in config.options) {
let option = config.options[i];
if (typeof option === "object") {
if (typeof option.val !== "undefined") this.options[i] = option.val / 100;
if (typeof option.pct !== "undefined") this.options[i] = option.pct / 100;
else if (typeof option.mm !== "undefined") this.options[i] = option.mm;
else if (typeof option.angle !== "undefined")
this.options[i] = option.angle;
else if (typeof option.deg !== "undefined") this.options[i] = option.deg;
else if (typeof option.dflt !== "undefined")
this.options[i] = option.dflt;
else throw "Unknown option type";
} else if (typeof option === "number") {
} else {
this.options[i] = option;
}
}