User:Eleanorg/Thematic1.1/Manipulate Longitude 1

From XPUB & Lens-Based wiki
< User:Eleanorg
Revision as of 14:08, 30 November 2011 by Eleanorg (talk | contribs)
#!/usr/bin/python
#-*- coding:utf-8 -*-


# first stab at turning a longitude position into a hexadecimal colour, using lorem longitude no.
# numbers actually need some manipulation so that colour differences are visible - split them?

import re

longitude = str(002.9999) # must be a string for regex to work
longint = re.sub("\.", "", longitude) # removes decimal point, leaving a number between 12528 (harwich) a$
hexcode = "#0" + longint

print "Content-Type: text/html"
print
print """
  <html>
    <body>
       <div style="width: 300px; height: 300px; background-color: """ + hexcode + """;">
         <p>""" + hexcode + """</p>
       </div>
    </body>
  </html>"""