From 5b9f9d7198f775a1f632194fb53b6bfe4da59b22 Mon Sep 17 00:00:00 2001 From: JauernigIT Date: Thu, 24 Mar 2016 21:39:39 +0100 Subject: [PATCH] inputStream.area to allow px values --- src/common/cv_utils.js | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/common/cv_utils.js b/src/common/cv_utils.js index 18485fd..96e7040 100644 --- a/src/common/cv_utils.js +++ b/src/common/cv_utils.js @@ -698,32 +698,32 @@ CVUtils.calculatePatchSize = function(patchSize, imgSize) { CVUtils._parseCSSDimensionValues = function(value) { var dimension = { value: parseFloat(value), - unit: value.indexOf("%") === value.length - 1 ? "%" : "%" + unit: value.indexOf("%") === value.length - 1 ? "%" : "px" }; return dimension; }; CVUtils._dimensionsConverters = { - top: function(dimension, context) { - if (dimension.unit === "%") { - return Math.floor(context.height * (dimension.value / 100)); - } + top: function top(dimension, context) { + return Math.floor((dimension.unit === "%") + ? (context.height * (dimension.value / 100)) + : dimension.value); }, - right: function(dimension, context) { - if (dimension.unit === "%") { - return Math.floor(context.width - (context.width * (dimension.value / 100))); - } + right: function right(dimension, context) { + return Math.floor((dimension.unit === "%") + ? (context.width - context.width * (dimension.value / 100)) + : (context.width - dimension.value)); }, - bottom: function(dimension, context) { - if (dimension.unit === "%") { - return Math.floor(context.height - (context.height * (dimension.value / 100))); - } + bottom: function bottom(dimension, context) { + return Math.floor((dimension.unit === "%") + ? (context.height - context.height * (dimension.value / 100)) + : (context.height - dimension.value)); }, - left: function(dimension, context) { - if (dimension.unit === "%") { - return Math.floor(context.width * (dimension.value / 100)); - } + left: function left(dimension, context) { + return Math.floor((dimension.unit === "%") + ? (context.width * (dimension.value / 100)) + : dimension.value); } };