def mandelbro(): x1 = float(request.args.get('x1')) y1 = float(request.args.get('y1')) x2 = float(request.args.get('x2')) y2 = float(request.args.get('y2')) witdh = int(request.args.get('witdh')) mandelbrot.renderizaMandelbrot(x1, y1, x2, y2, witdh, 20, "static/foto.png") image = '<img src=' + url_for('static', filename='foto.png') + '>' return image
def imagenDinamica(): x1 = float(request.args.get('x1')) x2 = float(request.args.get('x2')) y1 = float(request.args.get('y1')) y2 = float(request.args.get('y2')) ancho = int(request.args.get('ancho')) nombre_imagen = "static/imgs/mandel" + str(x1) + str(y1) + str(x2) + str( y2) + str(ancho) + ".png" nombre_imagen2 = "imgs/mandel" + str(x1) + str(y1) + str(x2) + str( y2) + str(ancho) + ".png" #sistema de cache if Path(nombre_imagen).is_file(): return '<img src="' + url_for('static', filename=nombre_imagen2) + '" </img>' else: mandelbrot.renderizaMandelbrot(x1, y1, x2, y2, ancho, 200, nombre_imagen) return '<img src="' + url_for('static', filename=nombre_imagen2) + '" </img>'
def prog(): clean_cache() x1 = request.args.get('x1') # x1 y1 = request.args.get('y1') # y1 x2 = request.args.get('x2') # x2 y2 = request.args.get('y2') # y2 ancho = request.args.get('ancho') # ancho archivo = "fractal" + "_x1" + str(x1) + "_y1" + str(y1) + "_x2" + str( x2) + "_y2" + str(y2) + "_a" + str(ancho) + ".png" url = 'http://0.0.0.0:8080/png/' + archivo my_file = Path('./static/imagenes/fractales/archivo') if not my_file.exists(): renderizaMandelbrot(float(x1), float(y1), float(x2), float(y2), int(ancho), 100, './static/imagenes/fractales/' + archivo) return redirect(url, code=302)
def generarmandelbrot(num): #num = request.args.get('num') #f = nombre #if(f == None): f = "./static/nombreDefault.png" #else: # f = "./static/"+str(f)+".png" if(num != None): if(num == 1): mandelbrot.renderizaMandelbrot(float(-1.0),float(-1.0),float(1.0),float(1.0),int(300),int(100),str(f)) elif (num == 2): mandelbrot.renderizaMandelbrot(float(-0.5),float(-0.5),float(0.5),float(0.5),int(250),int(75),str(f)) else: mandelbrot.renderizaMandelbrot(float(0.5),float(1.0),float(-0.5),float(-1.0),int(300),int(100),str(f)) return '<img src="/static/nombreDefault.png">'
def mandelbrot(): try: username = session['usuario'] historial[username].append("/mandelbrot") except: username = "******" img_dir = DIR + '/static/img/mandelbrot/' x1 = float(request.args['x1']) y1 = float(request.args['y1']) x2 = float(request.args['x2']) y2 = float(request.args['y2']) width = int(request.args['width']) iterations = int(request.args['iterations']) nombreimg = img_dir + str(x1) + str(y1) + str(x2) + str(y2) + str( width) + str(iterations) + ".png" if (os.path.isfile(nombreimg)): print("cacheando fractal") return send_file(nombreimg, mimetype='image/gif') else: print("no esta en cache") img = renderizaMandelbrot(x1, y1, x2, y2, width, iterations, nombreimg) return send_file(nombreimg, mimetype='image/gif')