Difference between revisions of "User:Maze/coolscale.py"
From Eth0Wiki
(New page: = Code= <pre> #! /usr/bin/env python # dirty coolscale generator, yes this could be written in far less lines, # care-- and lazy++ :) # # - maze import sys if len(sys.argv) != 2 or not ...) |
(No difference)
|
Latest revision as of 13:29, 29 January 2010
Code
#! /usr/bin/env python # dirty coolscale generator, yes this could be written in far less lines, # care-- and lazy++ :) # # - maze import sys if len(sys.argv) != 2 or not sys.argv[1].isdigit(): print >>sys.stderr, '%s <rows>' % (sys.argv[0],) rows = int(sys.argv[1]) bit = float(0xff) / float(rows) print '{|' for x in xrange(0, rows): if x > 0: c = 0xff - (bit * x) else: c = 0xff if x == 0: d = 0x00 elif x < (rows - 1): d = 0x00 + (bit * x) else: d = 0xff if x: print '|-' print '|style="background:#%02X00%02X;color:#FFF"|..' % (c, d) print '|}'
Example
maze@yourbox ~# python coolscale.py 42
.. |
.. |
.. |
.. |
.. |
.. |
.. |
.. |
.. |
.. |
.. |
.. |
.. |
.. |
.. |
.. |
.. |
.. |
.. |
.. |
.. |
.. |
.. |
.. |
.. |
.. |
.. |
.. |
.. |
.. |
.. |
.. |
.. |
.. |
.. |
.. |
.. |
.. |
.. |
.. |
.. |
.. |