001    package railo.runtime.functions.image;
002    
003    import railo.runtime.PageContext;
004    import railo.runtime.exp.FunctionException;
005    import railo.runtime.exp.PageException;
006    import railo.runtime.img.Image;
007    import railo.runtime.op.Caster;
008    
009    public class ImageDrawRect {
010    
011            public static String call(PageContext pc, Object name, double x, double y, double width,double height) throws PageException {
012                    return call(pc, name, x, y, width, height,false);
013            }
014            public static String call(PageContext pc, Object name, double x, double y, double width,double height, boolean filled) throws PageException {
015                    if(name instanceof String) name=pc.getVariable(Caster.toString(name));
016                    Image img = Image.toImage(name);
017                    
018                    if (width < 0)
019                        throw new FunctionException(pc,"ImageDrawRect",3,"width","width must contain a none negative value");
020                    if (height < 0)
021                        throw new FunctionException(pc,"ImageDrawRect",4,"height","width must contain a none negative value");
022                    
023                    img.drawRect((int)x, (int)y, (int)width, (int)height, filled);
024                    return null;
025            }
026            
027    }