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)
|
Title)
|
||||||
# echo strips leading and trailing whitespace
|
# echo strips leading and trailing whitespace
|
||||||
title=$(echo $value)
|
title=$(echo $value)
|
||||||
break
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
cat | markdown | m4 -DTITLE="$title" $1 -
|
markdown | m4 -DTITLE="$title" $1 -
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
SubDir TOP papers ;
|
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
|
concept to someone on woozle. Hopefully other people will find them
|
||||||
useful, too.
|
useful, too.
|
||||||
|
|
||||||
|
* ["Tank Tread" key-signing protocol](tank-tread.html)
|
||||||
* [Reply-To Munging Still Considered Harmful](reply-to-still-harmful.html)
|
* [Reply-To Munging Still Considered Harmful](reply-to-still-harmful.html)
|
||||||
* [Introduction to TCP Sockets](sockets.html)
|
* [Introduction to TCP Sockets](sockets.html)
|
||||||
* [3-Minute HTML Tutorial](html-tutorial.html)
|
* [3-Minute HTML Tutorial](html-tutorial.html)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#body {
|
body {
|
||||||
max-width: 100%;
|
max-width: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
span.cntrl {
|
span.cntrl {
|
||||||
|
@ -71,7 +71,7 @@ div.title, a.title {
|
||||||
}
|
}
|
||||||
|
|
||||||
a.title:hover {
|
a.title:hover {
|
||||||
background-color: #d9d8d1;
|
background-color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.title_text {
|
div.title_text {
|
||||||
|
@ -184,19 +184,19 @@ th {
|
||||||
}
|
}
|
||||||
|
|
||||||
tr.light:hover {
|
tr.light:hover {
|
||||||
background-color: #edece6;
|
background-color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
tr.dark {
|
tr.dark {
|
||||||
background-color: #f6f6f0;
|
background-color: #c6c6c0;
|
||||||
}
|
}
|
||||||
|
|
||||||
tr.dark2 {
|
tr.dark2 {
|
||||||
background-color: #f6f6f0;
|
background-color: #c6c6c0;
|
||||||
}
|
}
|
||||||
|
|
||||||
tr.dark:hover {
|
tr.dark:hover {
|
||||||
background-color: #edece6;
|
background-color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
td {
|
td {
|
||||||
|
|
|
@ -114,25 +114,42 @@ def ascii_test():
|
||||||
## Tartan junk
|
## Tartan junk
|
||||||
##
|
##
|
||||||
|
|
||||||
colors = {'R': Yarn(0.50, 0.00, 0.00), # Red
|
#
|
||||||
'G': Yarn(0.00, 0.30, 0.00), # Green
|
# Colors according to http://www.tartanregister.gov.uk/guidance.aspx
|
||||||
'B': Yarn(0.00, 0.00, 0.50), # Blue
|
#
|
||||||
'C': Yarn(0.00, 0.25, 0.25), # Cyan
|
colors = [('A', '\x00\x44\x99'), # Azure (light blue)
|
||||||
'Y': Yarn(0.80, 0.80, 0.00), # Yellow
|
('B', '\x00\x00\x44'), # Blue
|
||||||
'P': Yarn(0.60, 0.00, 0.60), # Purple (?!)
|
('C', '\xdc\x14\x3c'), # Crimson
|
||||||
'W': Yarn(0.60, 0.60, 0.60), # White
|
('G', '\x00\x44\x00'), # Green
|
||||||
'K': Yarn(0.00, 0.00, 0.00), # Black
|
('K', '\x00\x00\x00'), # Black
|
||||||
'BK': Yarn(0.00, 0.00, 0.00), # Black
|
('Mn', '\x80\x00\x00'), # Maroon
|
||||||
'GR': Yarn(0.25, 0.25, 0.25), # Gray
|
('N', '\x44\x44\x44'), # Neutral (gray)
|
||||||
'DB': Yarn(0.00, 0.00, 0.30), # Dark Blue
|
('P', '\x99\x00\x99'), # Purple
|
||||||
'LB': Yarn(0.00, 0.25, 0.60), # Light Blue
|
('R', '\x99\x00\x00'), # Red (scarlet)
|
||||||
'LR': Yarn(0.60, 0.00, 0.00), # Light Red
|
('T', '\x66\x66\x00'), # Tan (brown)
|
||||||
'LG': Yarn(0.00, 0.60, 0.00), # Light Green
|
('W', '\x99\x99\x99'), # White
|
||||||
'LV': Yarn(0.50, 0.25, 0.60), # Lavender
|
('Y', '\x99\x99\x00'), # Yellow
|
||||||
'BR': Yarn(0.30, 0.25, 0.00), # Brown
|
]
|
||||||
'LGR': Yarn(0.60, 0.60, 0.60), # Light Gray
|
if True:
|
||||||
'LBR': Yarn(0.40, 0.40, 0.00), # Light Brown
|
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
|
||||||
|
'Y': Yarn(0.80, 0.80, 0.00), # Yellow
|
||||||
|
'P': Yarn(0.60, 0.00, 0.60), # Purple (?!)
|
||||||
|
'W': Yarn(0.60, 0.60, 0.60), # White
|
||||||
|
'K': Yarn(0.00, 0.00, 0.00), # Black
|
||||||
|
'BK': Yarn(0.00, 0.00, 0.00), # Black
|
||||||
|
'GR': Yarn(0.25, 0.25, 0.25), # Gray
|
||||||
|
'DB': Yarn(0.00, 0.00, 0.30), # Dark Blue
|
||||||
|
'LB': Yarn(0.00, 0.25, 0.60), # Light Blue
|
||||||
|
'LR': Yarn(0.60, 0.00, 0.00), # Light Red
|
||||||
|
'LG': Yarn(0.00, 0.60, 0.00), # Light Green
|
||||||
|
'LV': Yarn(0.50, 0.25, 0.60), # Lavender
|
||||||
|
'BR': Yarn(0.30, 0.25, 0.00), # Brown
|
||||||
|
'LGR': Yarn(0.60, 0.60, 0.60), # Light Gray
|
||||||
|
'LBR': Yarn(0.40, 0.40, 0.00), # Light Brown
|
||||||
|
}
|
||||||
sett_re = re.compile('([A-Za-z]{1,3}|\([A-Fa-f0-9]{3}\))(\d{1,3})')
|
sett_re = re.compile('([A-Za-z]{1,3}|\([A-Fa-f0-9]{3}\))(\d{1,3})')
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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
|
#! /bin/sh
|
||||||
|
|
||||||
header () {
|
while IFS=: read key val; do
|
||||||
while IFS=: read key val; do
|
tval=$(echo $val | sed "s/'/\'/g")
|
||||||
tval=$(echo $val | sed "s/'/\'/g")
|
case $key in
|
||||||
case $key in
|
Name)
|
||||||
Name)
|
tartan="$tval"
|
||||||
echo -n "TARTAN='$tval';"
|
;;
|
||||||
;;
|
Sett)
|
||||||
Sett)
|
sett="$tval"
|
||||||
echo -n "SETT='$tval'"
|
;;
|
||||||
;;
|
"")
|
||||||
"")
|
break
|
||||||
break
|
;;
|
||||||
;;
|
esac
|
||||||
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