From a63f1ffb1cb2bcf6bd9a6328f2844a6b15445bef Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Wed, 16 Nov 2016 17:48:17 -0800 Subject: [PATCH] Dynamic width and height are working. --- scripts/command.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/command.js b/scripts/command.js index 5687b79..12eea57 100644 --- a/scripts/command.js +++ b/scripts/command.js @@ -20,7 +20,18 @@ function Command(content) function converter(str) { - if(str == "50w"){ return "123"; } + var unit = str.charAt(str.length - 1); + var value = parseFloat(str.replace(unit,'')); + + switch(unit) { + case "w": + return ronin.canvas.element.width * (value/100); + break; + case "h": + return ronin.canvas.element.height * (value/100); + break; + } + return str; }