User:Joak/colorroute

From XPUB & Lens-Based wiki
< User:Joak
Revision as of 00:04, 9 July 2013 by Joak (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

python script for generating 1.677.216 html files with different backgroundcolors. Each html-file is linked with the java-script "window.location.href" to the next html-file - that means you will start with background-color #000000 and end with #ffffff!

#!/usr/bin/env python

for x in range(0, 16777216): 
	name = hex(x).lstrip("0x")
	neext = hex(x+1).lstrip("0x")
	while len(name) < 6:
		name = "0" + name
	while len(neext) < 6:
		neext = "0" + neext
	file=open("tests/"+name+".html","w+")
	if x == 16777215: 
		file.write("""<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>the famous color route #"""+name+""""</title>
<meta name="author" content="joak">
<script language="javascript" type="text/javascript">
	window.setTimeout("window.location = '000000.html'",5000);
</script>
</head>
<body bgcolor="#"""+name+"""">
<div style="position:absolute;left:50%;top:50%;"><center><input type="button" onclick="window.location.href = '000000.html';" value="again"></center></div>
</body>
</html>""")
	else: 
		file.write("""<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>the famous color route #"""+name+""""</title>
<meta name="author" content="joak">
<script language="javascript" type="text/javascript">
	window.setTimeout("window.location = '"""+neext+""".html'",0);
</script>
</head>
<body bgcolor="#"""+name+"""">
</body>
</html>""")
	file.close()
	print name
</>

screenshot as example(b-color #0000d7): Colorroute.png