use of lucee.runtime.img.filter.LightFilter.Material in project Lucee by lucee.
the class ImageFilterUtil method toLightFilter$Material.
public static LightFilter.Material toLightFilter$Material(Object value, String argName) throws PageException {
if (value instanceof LightFilter.Material)
return (LightFilter.Material) value;
Struct sct = Caster.toStruct(value, null);
if (sct != null) {
Material material = new LightFilter.Material();
material.setDiffuseColor(toColorRGB(sct.get("color"), argName + ".color"));
material.setOpacity(Caster.toFloatValue(sct.get("opacity")));
return material;
}
String str = Caster.toString(value, null);
if (str != null) {
String[] arr = ListUtil.listToStringArray(str, ',');
if (arr.length == 2) {
Material material = new LightFilter.Material();
material.setDiffuseColor(toColorRGB(arr[0], argName + "[1]"));
material.setOpacity(Caster.toFloatValue(arr[1]));
return material;
}
throw new FunctionException(ThreadLocalPageContext.get(), "ImageFilter", 3, "parameters", "use the following format [color,opacity]");
}
throw new FunctionException(ThreadLocalPageContext.get(), "ImageFilter", 3, "parameters", "use the following format [\"color,opacity\"] or [{color='#cc0033',opacity=0.5}]");
}
Aggregations