i have this piece of code and i cant figure out what it's trying to accomplish with its logic. It's just the cases "-1" and "1".
Some Context:
- This is part of a function, which resizes images for a webpage.
- We have the dimensions of the original image and desired sizes, which are given as arguments.
- It is possible that the desired size is just a width or just a height, in either way the empty value will be replaced with the original width/height.
I am trying to rewrite the code..
If it does matter, this is coldfusion and "arguments", "local" and "variables" are scopes, kind of namespaces, where variables can be stored.
arguments.width = isNumeric(arguments.width) ? arguments.width : variables.getOrgWidth();
arguments.height = isNumeric(arguments.height) ? arguments.height : variables.getOrgHeight();
switch (arguments.ratio) {
case "-1":
// What does this do?
if ((variables.getOrgWidth() / arguments.width) LT (variables.getOrgHeight() / arguments.height)) {
local.targetSize = "#arguments.width#"
} else {
local.targetSize = "x#arguments.height#"
}
break;
case "0":
// Force desired width and heigth, even if its distorts
local.targetSize = "#arguments.width#x#arguments.height#!"
break;
case "1":
// What does this do??
if ((variables.getOrgWidth() / arguments.width) GT (variables.getOrgHeight() / arguments.height)) {
local.targetSize = "#arguments.width#"
} else {
local.targetSize = "x#arguments.height#"
}
break;
case "2":
// transform dimensions based on desired width, the height will be calculated
local.targetSize = "#arguments.width#"
break;
case "3":
// transform dimensions based on desired height, the width will be calculated
local.targetSize = "x#arguments.height#"
break;
}
Aucun commentaire:
Enregistrer un commentaire