March 2010 snapshot
This commit is contained in:
parent
60d47455d6
commit
6d89ad8bf5
Binary file not shown.
After Width: | Height: | Size: 33 KiB |
Binary file not shown.
After Width: | Height: | Size: 980 KiB |
|
@ -8,9 +8,8 @@ while IFS=: read field value; do
|
|||
Title)
|
||||
# echo strips leading and trailing whitespace
|
||||
title=$(echo $value)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
cat | markdown | m4 -DTITLE="$title" $1 -
|
||||
markdown | m4 -DTITLE="$title" $1 -
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
SubDir TOP papers ;
|
||||
|
||||
Webify index.mdwn reply-to-still-harmful.mdwn sockets.mdwn DNS.mdwn html-tutorial.mdwn digimatrix.mdwn ;
|
||||
Webify index.mdwn reply-to-still-harmful.mdwn sockets.mdwn DNS.mdwn html-tutorial.mdwn digimatrix.mdwn tank-tread.mdwn ;
|
||||
|
|
|
@ -4,6 +4,7 @@ These are papers I have written. Most of them were written to explain a
|
|||
concept to someone on woozle. Hopefully other people will find them
|
||||
useful, too.
|
||||
|
||||
* ["Tank Tread" key-signing protocol](tank-tread.html)
|
||||
* [Reply-To Munging Still Considered Harmful](reply-to-still-harmful.html)
|
||||
* [Introduction to TCP Sockets](sockets.html)
|
||||
* [3-Minute HTML Tutorial](html-tutorial.html)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#body {
|
||||
max-width: 100%;
|
||||
body {
|
||||
max-width: inherit;
|
||||
}
|
||||
|
||||
span.cntrl {
|
||||
|
@ -71,7 +71,7 @@ div.title, a.title {
|
|||
}
|
||||
|
||||
a.title:hover {
|
||||
background-color: #d9d8d1;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
div.title_text {
|
||||
|
@ -184,19 +184,19 @@ th {
|
|||
}
|
||||
|
||||
tr.light:hover {
|
||||
background-color: #edece6;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
tr.dark {
|
||||
background-color: #f6f6f0;
|
||||
background-color: #c6c6c0;
|
||||
}
|
||||
|
||||
tr.dark2 {
|
||||
background-color: #f6f6f0;
|
||||
background-color: #c6c6c0;
|
||||
}
|
||||
|
||||
tr.dark:hover {
|
||||
background-color: #edece6;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
td {
|
||||
|
|
|
@ -114,7 +114,24 @@ def ascii_test():
|
|||
## Tartan junk
|
||||
##
|
||||
|
||||
colors = {'R': Yarn(0.50, 0.00, 0.00), # Red
|
||||
#
|
||||
# Colors according to http://www.tartanregister.gov.uk/guidance.aspx
|
||||
#
|
||||
colors = [('A', '\x00\x44\x99'), # Azure (light blue)
|
||||
('B', '\x00\x00\x44'), # Blue
|
||||
('C', '\xdc\x14\x3c'), # Crimson
|
||||
('G', '\x00\x44\x00'), # Green
|
||||
('K', '\x00\x00\x00'), # Black
|
||||
('Mn', '\x80\x00\x00'), # Maroon
|
||||
('N', '\x44\x44\x44'), # Neutral (gray)
|
||||
('P', '\x99\x00\x99'), # Purple
|
||||
('R', '\x99\x00\x00'), # Red (scarlet)
|
||||
('T', '\x66\x66\x00'), # Tan (brown)
|
||||
('W', '\x99\x99\x99'), # White
|
||||
('Y', '\x99\x99\x00'), # Yellow
|
||||
]
|
||||
if True:
|
||||
colors = {'R': Yarn(0.50, 0.00, 0.00), # Red
|
||||
'G': Yarn(0.00, 0.30, 0.00), # Green
|
||||
'B': Yarn(0.00, 0.00, 0.50), # Blue
|
||||
'C': Yarn(0.00, 0.25, 0.25), # Cyan
|
||||
|
|
|
@ -1,117 +0,0 @@
|
|||
#! /usr/bin/python
|
||||
|
||||
import sys
|
||||
import Image
|
||||
import re
|
||||
import array
|
||||
|
||||
colors = {'R': '\x88\x00\x00', # Red
|
||||
'G': '\x00\x44\x00', # Green
|
||||
'B': '\x00\x00\x44', # Blue
|
||||
'C': '\x00\x44\x44', # Cyan
|
||||
'Y': '\x99\x99\x00', # Yellow
|
||||
'P': '\x99\x00\x99', # Purple (?!)
|
||||
'W': '\x99\x99\x99', # White
|
||||
'K': '\x00\x00\x00', # Black
|
||||
'BK': '\x00\x00\x00', # Black
|
||||
'GR': '\x44\x44\x44', # Gray
|
||||
'DB': '\x00\x00\x55', # Dark Blue
|
||||
'LB': '\x00\x44\x99', # Light Blue
|
||||
'LR': '\x99\x00\x00', # Light Red
|
||||
'LG': '\x00\x99\x00', # Light Green
|
||||
'LV': '\x88\x44\x99', # Lavender
|
||||
'BR': '\x55\x44\x00', # Brown
|
||||
'LGR': '\x99\x99\x99', # Light Gray
|
||||
'LBR': '\x66\x66\x00', # Light Brown
|
||||
}
|
||||
sett_re = re.compile('([A-Za-z]{1,3}|\([A-Fa-f0-9]{3}\))(\d{1,3})')
|
||||
|
||||
def str_to_sett(s):
|
||||
"""Convert an xtartan sett string into a sett tuple."""
|
||||
|
||||
sett = []
|
||||
while s:
|
||||
m = sett_re.search(s)
|
||||
if not m:
|
||||
break
|
||||
cs = m.group(1)
|
||||
if cs[0] == '(' and cs[-1] == ')':
|
||||
ca = array.array('B')
|
||||
for a in cs[1:-1]:
|
||||
ca.append(int(a+a, 16))
|
||||
c = ca.tostring()
|
||||
else:
|
||||
c = colors[cs]
|
||||
n = int(m.group(2))
|
||||
sett.append((c, n))
|
||||
s = s[m.end():]
|
||||
if not s.endswith('.'):
|
||||
o = sett[:]
|
||||
o.reverse()
|
||||
sett += o
|
||||
return sett
|
||||
|
||||
|
||||
|
||||
class Loom:
|
||||
"""Simulates a simple loom with only one weft color per row.
|
||||
|
||||
This probably does a simplistic weave too, I don't know enough about
|
||||
weaving to say for sure. But I can imagine more complicated ways of
|
||||
doing it.
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, warp):
|
||||
self.warp = warp
|
||||
self.cloth = []
|
||||
self.row = 0
|
||||
|
||||
def weave(self, weft):
|
||||
out = []
|
||||
for i in range(len(self.warp)):
|
||||
if (i + self.row) % 2 == 0:
|
||||
out.append(weft)
|
||||
else:
|
||||
out.append(self.warp[i])
|
||||
|
||||
self.cloth.append(out)
|
||||
self.row += 1
|
||||
|
||||
|
||||
class Tartan:
|
||||
def __init__(self, sett):
|
||||
# Weave a whole pattern suitable for tiling. In other words, it
|
||||
# does the mirroring for you.
|
||||
|
||||
if type(sett) == type(''):
|
||||
sett = str_to_sett(sett)
|
||||
|
||||
warp = []
|
||||
for c,n in sett:
|
||||
warp += [c]*n
|
||||
|
||||
if False:
|
||||
# Offset it to the center of the first dealie
|
||||
o = sett[0][1] / 2
|
||||
warp += warp[:o]
|
||||
del warp[:o]
|
||||
|
||||
self.loom = Loom(warp)
|
||||
for w in warp:
|
||||
self.loom.weave(w)
|
||||
|
||||
rgbs = [''.join(x) for x in self.loom.cloth]
|
||||
imgstr = ''.join(rgbs)
|
||||
self.img = Image.fromstring('RGB',
|
||||
(len(self.loom.cloth[1]),
|
||||
len(self.loom.cloth)),
|
||||
imgstr)
|
||||
|
||||
def png(self, fd):
|
||||
self.img.save(fd, 'PNG')
|
||||
|
||||
if __name__ == '__main__':
|
||||
sett = sys.argv[1]
|
||||
t = Tartan(sett)
|
||||
t.png(sys.stdout)
|
|
@ -1,22 +1,19 @@
|
|||
#! /bin/sh
|
||||
|
||||
header () {
|
||||
while IFS=: read key val; do
|
||||
while IFS=: read key val; do
|
||||
tval=$(echo $val | sed "s/'/\'/g")
|
||||
case $key in
|
||||
Name)
|
||||
echo -n "TARTAN='$tval';"
|
||||
tartan="$tval"
|
||||
;;
|
||||
Sett)
|
||||
echo -n "SETT='$tval'"
|
||||
sett="$tval"
|
||||
;;
|
||||
"")
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
done
|
||||
|
||||
eval $(header)
|
||||
m4 -DTARTAN="$TARTAN" -DSETT="$SETT" -DIMAGE="$1" $2 -
|
||||
m4 -DTARTAN="$tartan" -DSETT="$sett" -DIMAGE="$1" $2 -
|
||||
|
||||
|
|
Loading…
Reference in New Issue