--- fract/mandelzoom.cgi 2001/02/24 21:36:47 1.1 +++ fract/mandelzoom.cgi 2001/02/25 05:49:07 1.2 @@ -1,39 +1,52 @@ #!/usr/bin/python -import cgi, Image, ImageDraw, sys -from string import atoi +import cgi, Image, ImageDraw, sys, math +from string import atoi, atof + +sys.stderr = sys.stdout form= cgi.FieldStorage() # Image size if form.has_key('width'): - width=atoi(form['width'].value) + width= atoi(form['width'].value) else: width= 570 if form.has_key('height'): - height=atoi(form['height'].value) + height= atoi(form['height'].value) else: height= 570 xmax, ymax = width-1, height-1 # Coordinate maximums +# Complex number in center of image is (cx+cy*j) +if form.has_key('cx'): + cx= atof(form['cx'].value) +else: + cx= 0 + +if form.has_key('cy'): + cy= atof(form['cy'].value) +else: + cy= 0 + +if form.has_key('diag'): + diag= atof(form['diag'].value) +else: + diag= math.sqrt(8) + debug= form.has_key('debug') -if debug: - del form['debug'] if form.has_key('iter'): - maxiter=atoi(form['iter'].value) - del form['iter'] + maxiter= atoi(form['iter'].value) else: maxiter= 270 -sys.stderr = sys.stdout -print "Content-Type: text/plain" -print "" +#print "Content-Type: text/plain" +#print "" -# If type==html, then output an HTML page, not an image -if form.has_key('type') and form['type'].value == "html": - del form['type'] +# If type!=image, then output an HTML page, not an image +if not (form.has_key('type') and form['type'].value == "image"): print """Content-Type: text/html @@ -45,14 +58,49 @@
- - +""" + print '

' % (str(width)) + print 'Zoom: ' + print """Width: + Height: Iterations: - Debug mode: """ + Debug mode: ' + else: + print '>' for key in form.keys(): - print '' % (key, form[key].value) + if key not in ["zoom", "type", "debug", "image.x", "image.y", "iter", "height", "width"]: + print '' % (key, form[key].value) + print '' print """

"""