User:Eleanorg/Thematic1.1/Manipulate Longitude 1: Difference between revisions
(Created page with "<source lang=python> #!/usr/bin/python #-*- coding:utf-8 -*- # first stab at turning a longitude position into a hexadecimal colour, using lorem longitude no. # numbers actual...") |
No edit summary |
||
Line 12: | Line 12: | ||
longitude = str(002.9999) # must be a string for regex to work | 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$ | longint = re.sub("\.", "", longitude) # removes decimal point, leaving a number between 12528 (harwich) a$ | ||
hexcode = "#0" + longint | hexcode = "#0" + longint | ||
Revision as of 14:08, 30 November 2011
#!/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>"""