Search in sources :

Example 1 with Material

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}]");
}
Also used : FunctionException(lucee.runtime.exp.FunctionException) Material(lucee.runtime.img.filter.LightFilter.Material) Struct(lucee.runtime.type.Struct)

Aggregations

FunctionException (lucee.runtime.exp.FunctionException)1 Material (lucee.runtime.img.filter.LightFilter.Material)1 Struct (lucee.runtime.type.Struct)1