| 38 |
if form.has_key('diag'): |
if form.has_key('diag'): |
| 39 |
diag= atof(form['diag'].value) |
diag= atof(form['diag'].value) |
| 40 |
else: |
else: |
| 41 |
diag= math.sqrt(8) |
diag= math.sqrt(32) # sqrt(4**2 + 4**2) |
| 42 |
|
|
| 43 |
debug= form.has_key('debug') |
debug= form.has_key('debug') |
| 44 |
|
|
| 45 |
if form.has_key('iter'): |
if form.has_key('iter'): |
| 46 |
maxiter= atoi(form['iter'].value) |
maxiter= atoi(form['iter'].value) |
| 47 |
else: |
else: |
| 48 |
maxiter= 240 |
maxiter= 270 |
| 49 |
|
|
| 50 |
# If type!=image, then output an HTML page, not an image |
# If type!=image, then output an HTML page, not an image |
| 51 |
if not (form.has_key('type') and form['type'].value == "image"): |
if not (form.has_key('type') and form['type'].value == "image"): |
| 69 |
else: |
else: |
| 70 |
ds="" |
ds="" |
| 71 |
if form.has_key('zoom'): |
if form.has_key('zoom'): |
| 72 |
zoom=atoi(form['zoom'].value) |
zoom=atof(form['zoom'].value) |
| 73 |
diag=diag/zoom |
diag=diag/zoom |
| 74 |
else: |
else: |
| 75 |
# If no zoom provided, don't actually zoom |
# If no zoom provided, don't actually zoom |
| 78 |
print 'ALIGN=BOTTOM HEIGHT="%s"' % (str(height)), |
print 'ALIGN=BOTTOM HEIGHT="%s"' % (str(height)), |
| 79 |
print 'WIDTH="%s"><P>' % (str(width)) |
print 'WIDTH="%s"><P>' % (str(width)) |
| 80 |
print 'Zoom: <SELECT NAME="zoom">' |
print 'Zoom: <SELECT NAME="zoom">' |
| 81 |
for zv in [1.0/5, 1.0/3, 1.0/2, 1.0/1.5, 1, 1.5, 2, 3, 5]: |
for zv in [1.0/5, 1.0/3, 1.0/2, 1.0/1.5, 1.0, 1.5, 2.0, 3.0, 5.0]: |
| 82 |
print '<OPTION', |
print '<OPTION', |
| 83 |
if zv==zoom: |
if str(zv)==str(zoom): |
| 84 |
print 'SELECTED', |
print 'SELECTED', |
| 85 |
print 'VALUE="%s"' % (str(zv)) |
print 'VALUE="%s"' % (str(zv)) |
| 86 |
if zv == 1: |
if zv == 1: |
| 105 |
else: |
else: |
| 106 |
print '>' |
print '>' |
| 107 |
print '<INPUT TYPE=SUBMIT VALUE="Apply">' |
print '<INPUT TYPE=SUBMIT VALUE="Apply">' |
| 108 |
for key in form.keys(): |
for var in (("diag", diag), ("cx", cx), ("cy", cy)): |
| 109 |
if key not in ["zoom", "type", "debug", "image.x", "image.y", "iter", "height", "width"]: |
print '<INPUT TYPE=HIDDEN NAME="%s" VALUE="%s">' % var |
|
print '<INPUT TYPE=HIDDEN NAME="%s" VALUE="%s">' % (key, form[key].value) |
|
|
#for var in [("diag", diag), ("cx", cx), ("cy", cy)]: |
|
|
|
|
| 110 |
print '<INPUT TYPE=HIDDEN NAME=type VALUE="html">' |
print '<INPUT TYPE=HIDDEN NAME=type VALUE="html">' |
| 111 |
|
|
| 112 |
print """</FORM> |
print """</FORM> |
| 113 |
</BODY></HTML>""" |
</BODY></HTML>""" |
| 114 |
sys.exit(0) |
sys.exit(0) |
| 115 |
|
|
| 116 |
c1, c2 = (-2+2j), (2-2j) # Corner coordinates |
# Figure out c1 and c2 from width, height, diag, cx, and cy. |
| 117 |
|
# Diagonal in pixels |
| 118 |
|
diagp= math.sqrt(width**2 + height**2) |
| 119 |
|
# Scale between pixels and coordinates |
| 120 |
|
scale= diagp/diag |
| 121 |
|
x= (width/2.0)/scale |
| 122 |
|
y= (height/2.0)/scale |
| 123 |
|
|
| 124 |
|
c1= cx - x + cy - y * (0+1j) |
| 125 |
|
c2= cx + x + cy + y * (0+1j) |
| 126 |
|
|
| 127 |
|
#print width, height, diag, cx, cy, diagp, scale, x, y, c1, c2 |
| 128 |
|
#sys.exit(0) |
| 129 |
|
|
| 130 |
|
#c1, c2 = (-2+2j), (2-2j) # Corner coordinates |
| 131 |
|
|
| 132 |
# Force c1 to be upper left and c2 to be lower right |
# Force c1 to be upper left and c2 to be lower right |
| 133 |
c1, c2= complex(min(c1.real, c2.real), max(c1.imag, c2.imag)), \ |
c1, c2= complex(min(c1.real, c2.real), max(c1.imag, c2.imag)), \ |