def inputs(req, shape): def color(var, info): if var in info: c = list(color_name_to_rgb("#%s" % info[var][:6])) c.reverse() if len(info[var])>6 and (info[var][6:8]).isdigit(): c.append(0.01*(int)(info[var][6:8])) #alpha is just numeric else: c.append(1) #assume if alpha not specified else: c=[0.5, 0.5, 0.5, 0.5] return c # Radius # Dimension # Border # Color1/Color2 # Extra info = req.form r = min(100, max(10, ('r' in info) and (int)(info['r']) or 100)) d = 'd' in info and [int(info['d']), int(info['d'])] or [32,32] b = 'b' in info and int(info['b']) or 8 c1 = color('c1', req.form) c2 = color('c2', req.form) ex = 'ex' in info and int(info['ex']) or None; drawer.drawShape(req, shape=shape, dimens=d, border=b, radius=r, bottom=True, color1=c1, color2=c2, extra=ex)
def image2(req): info = req.form r = min(100, max(10, ('r' in info) and (int)(info['r']) or 100)) if 'c0' in info: c = list(color_name_to_rgb("#%s" % info['c0'][:6])) c.reverse() #c = [float(x) for x in info['c0'].split("|")] if len(c)==3: c.append(1) #alpha, although we should change this else: colors = {0: [1, 1, 1, 0.5], 1:[0.8, 0, 0, 0.5], 2:[0.2, 0.8, 0, 0.5], 3:[0, 0.2, 0.8, 0.5]} c = colors[('c' in info) and (int)(info['c']) or 0] drawer.drawShape(req, dimens=[32,32], radius=r, bottom=True, color1=c, color2=[0.2, 0.2, 0.2, 1]) return apache.OK
def image3(req): info = req.form r = min(100, max(10, ('r' in info) and (int)(info['r']) or 100)) d = 'd' in info and [int(info['d']), int(info['d'])] or [32,32] def color(var): if var in info: c = list(color_name_to_rgb("#%s" % info[var][:6])) c.reverse() #c = [float(x) for x in info['c0'].split("|")] if len(c)==3: c.append(1) #alpha, although we should change this else: c=[0.2, 0.2, 0.2, 1] return c c1 = color('c1') c2 = color('c2') drawer.drawShape(req, dimens=d, radius=100, bottom=True, color1=c1, color2=c2) return apache.OK