--- fract/mandelzoom.cgi 2001/02/26 03:13:13 1.6 +++ fract/mandelzoom.cgi 2001/06/26 12:43:34 1.10 @@ -1,8 +1,15 @@ #!/usr/bin/python -import cgi, Image, ImageDraw, sys, math +import cgi, Image, ImageDraw, sys, math, signal, errno, os from string import atoi, atof +def handler(signum, frame): + signal.alarm(0) + raise os.error, (errno.ETIME, "Timer expired") + +signal.alarm(55) +signal.signal(signal.SIGALRM, handler) + # This is to get backtrace output sys.stderr = sys.stdout @@ -35,6 +42,8 @@ else: cy= 0.0 +# The length of the diagonal line from corner to corner. +# Used as a measure of image size independent of aspect ratio. if form.has_key('diag'): diag= atof(form['diag'].value) else: @@ -68,21 +77,23 @@ ds="&debug=on" else: ds="" + # If the user has selected a specific point on the image if form.has_key('image.x') and form.has_key('image.y'): # Adjust cx and cy - ix= atof(form['image.x'].value) - iy= atof(form['image.y'].value) + ix= atof(form['image.x'].value) # Intermediate value + iy= atof(form['image.y'].value) # Intermediate value owidth= atof(form['owidth'].value) oheight= atof(form['oheight'].value) - diagp= math.sqrt(width**2 + height**2) - scale= diagp/diag - cx= (ix/scale) + (cx - (width / (scale*2))) - cy= ((height-iy)/scale) + (cy - (height / (scale*2))) + diagp= math.sqrt(owidth**2 + oheight**2) # Intermediate value + scale= diagp/diag # Intermediate value + cx= (ix/scale) + (cx - (owidth / (scale*2))) + cy= ((oheight-iy)/scale) + (cy - (oheight / (scale*2))) if form.has_key('zoom'): zoom=atof(form['zoom'].value) diag=diag/zoom else: - # If no zoom provided, don't actually zoom + # If no zoom provided, don't actually zoom, but keep the + # default of ×2 zoom. zoom= 2.0 print 'SRC="mandelzoom.cgi?type=image&width=%s&height=%s&iter=%s%s&diag=%s&cx=%s&cy=%s"' % (str(width), str(height), str(maxiter), ds, str(diag), str(cx), str(cy)), print 'ALIGN=BOTTOM HEIGHT="%s"' % (str(height)), @@ -117,31 +128,38 @@ print '' % var print '' - print """ + print """
+After changing any settings, don't forget to change the "Zoom" setting +to "Pan" if you don't want to zoom when applying them.