Commit c97158d5 authored by Ture Pålsson's avatar Ture Pålsson

Initial commit

parents
\def\c#1#2#3#4{% color fg name alt
\special{color push rgb #1}%
#3%
\kern .5em
\hbox to 3em{%
\vrule width 3em height 8pt depth 2pt
\hss
\hbox to 3em{\special{color pop}\special{color push rgb #2}\hfil#4\hfil}}
\special{color pop}%
}%
\font\f="Courier" at 10pt
\font\hf=cmr17
\footline={}
\hoffset=-1in
\hsize=210mm
\centerline{\hf XTerm colour codes}
\vskip 18pt
\f
\tabskip=0pt plus 1fill
\halign to \hsize{%
\vrule width 0pt height 10pt depth 5pt
#\quad\tabskip=0pt&
#\quad&#\quad&#\quad&#\quad
&#\tabskip=0pt plus 1fill\cr
\input coldata.tex
}
\bye
import sys
def ff(n):
return [0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff][n]
def c():
columns = 6
rows = 216 / columns
for row in range(0, rows):
items = []
for col in range(0, columns):
c = col * rows + row
red = ff(c // 36)
green = ff((c // 6) % 6)
blue = ff(c % 6)
grey = .21 * red + .71 * green + .07 * blue
fgcolor = (1, 1, 1) if grey < 128 else (0, 0, 0)
name = '%02x%02x%02x' % (red, green, blue)
alt = '%d' % (16 + c,)
items.append('\\c{%(r)f %(g)f %(b)f}'
'{%(fr)f %(fg)f %(fb)f}'
'{%(name)s}{%(alt)s}'
% {'r': red / 255.0,
'g': green / 255.0,
'b': blue / 255.0,
'fr': fgcolor[0], 'fg': fgcolor[1],
'fb': fgcolor[2],
'name': name,
'alt': alt})
sys.stdout.write('%s\\cr\n' % ('&'.join(items),))
if __name__ == '__main__':
c()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment