def imageify(args, name, destination): # Check against a clock so that marian doesn't get spammed. (Once every minute?) try: if len(args) >= 2: imageURL = args[1] xtrans = 0 ytrans = 0 scale = 1 sens = 550 if len(args) > 2: for arg in args: opt = arg.split("=") if len(opt) != 2: sendmsg(destination, "Invalid args! Possible args:") sendmsg(destination, "xtrans, ytrans, scale") return if opt[0] == "xtrans": xtrans = int(opt[1]) if xtrans > 1100 or xtrans < -1100: sendmsg(destination, "Your xtrans value must be within -1100 and 1100") return if opt[0] == "ytrans": ytrans = int(opt[1]) if ytrans > 1100 or ytrans < -1100: sendmsg(destination, "Your ytrans value must be within -1100 and 1100") return if opt[0] == "scale": scale = float(opt[1]) if scale > 10 or scale < 0.1: sendmsg(destination, "Your scale must be within 0.1 and 10") return if opt[0] == "sensitivity": sens = int(opt[1]) if sens <= 0: sendmsg(destination, "Your sensitivity must be greater than 0") return fcmlImage = FCMLImage(imageURL, xtrans, ytrans, scale, sens) fcml = fcmlImage.partition() # --------------------------------- # Do something clever with the fcml # --------------------------------- formattedfcml = FormattedFCML("newfile") formattedfcml.writeToFile(fcml) sendmsg(destination, formattedfcml.filePath) except Exception as e: # sendmsg(destination, "Something went wrong with your input") sendmsg(destination, "This feature is not yet implemented. Hang tight.") print(e)
def plot(args, name, destination): try: if len(args) >= 2: equation = args[1] xtrans = 0 ytrans = 0 xscale = 1 yscale = 1 xleftbound = -1000 xrightbound = 1000 numrects = 100 width = 10 recttype = "StaticRect" if len(args) > 1: for arg in args[2:]: opt = arg.split("=") if len(opt) != 2: sendmsg(destination, "Whoops! Your syntax is wrong..") return if opt[0] == "xtrans": xtrans = int(opt[1]) if opt[0] == "ytrans": ytrans = int(opt[1]) if opt[0] == "xscale": xscale = float(opt[1]) if xscale <= 0: sendmsg(destination, "Invalid xscale (must be greater than 0)") if opt[0] == "yscale": yscale = float(opt[1]) if yscale <= 0: sendmsg(destination, "Invalid yscale (must be greater than 0)") if opt[0] == "xleftbound": xleftbound = int(opt[1]) if opt[0] == "xrightbound": xrightbound = int(opt[1]) if opt[0] == "numrects": numrects = int(opt[1]) if numrects <=0: sendmsg(destination, "Invalid numrects (must be greater than 0)") if opt[0] == "width": width = int(opt[1]) if width < 0: sendmsg(destination, "Invalid width (must be greater than 0)") if opt[0] == "type": if "DYN" in opt[1].upper(): recttype = "DynamicRect" elif "STAT" in opt[1].upper(): pass else: sendmsg(destination, "Couldn't decipher your rectangle type. Going to default to StaticRect.") else: sendmsg(destination, "Looks like you have incorrect syntax somewhere...") fcmlfunc = FCMLFunction(equation, translateX=xtrans, translateY=ytrans, xScale=xscale, yScale=yscale, xLeftBound=xleftbound, xRightBound=xrightbound, numRects=numrects, width=width, recttype=recttype) fcml = fcmlfunc.toFCML() formattedfcml = FormattedFCML("equation") formattedfcml.writeToFile(fcml) sendmsg(destination, formattedfcml.filePath) else: sendmsg(destination, "Plot Usage: ") sendmsg(destination, "\t!plot [equation] [options]") sendmsg(destination, "----------------------------") sendmsg(destination, "Options: ") sendmsg(destination, "\txtrans/ytrans=X") sendmsg(destination, "\txscale/yscale=X") sendmsg(destination, "\txleftbound/yleftbound=X") sendmsg(destination, "\tnumrects=X") sendmsg(destination, "\twidth=X \\\\the width of the plotted line") except Exception as e: print e