Rework tartans

This commit is contained in:
Neale Pickett 2015-03-21 18:55:18 +00:00
parent 228ffc60c7
commit 8c7f9d2d99
31 changed files with 431 additions and 634 deletions

View File

@ -1,9 +0,0 @@
Name: Albuquerque
Sett: R4 G24 B4 G10 B36 W6 R4 W4
Created by Ralph Stevenson Jr and Charles Hargis in 2005 for the city's
tricentennial anniversary (1706-2006). It is similar in design to the
[New Mexico tartan](nm.html), with a little less green, and white instead of
yellow, with a thicker center band.
[Bally Dun Celtic Treasures](http://www.ballydun.com/) sells this tartan.

View File

@ -1,2 +0,0 @@
Name: Armstrong
Sett: G4 BK2 G60 BK24 B4 BK2 B2 BK2 B24 R6

View File

@ -1,6 +0,0 @@
Name: Arizona
Sett: W2 G3 R4 G28 B3 BR8
Based on a jpeg I found on a geocities homepage. Surprisingly,
that jpeg was the only mention I could find on the net of what
the actual sett was for Arizona.

View File

@ -1,4 +0,0 @@
Name: Black Watch
Sett: B22 BK2 B2 BK2 B2 BK16 G16 BK2 G16 BK16 B16 BK2 B2 BK2 G10 BK8 DB9 BK1 DB1
A standard.

View File

@ -1,4 +0,0 @@
Name: Buchanan
Sett: Y8 BK2 Y8 BK2 B6 BK2 G8 B4 G8 BK2 B6 BK2 LR10 W2 LR10 BK2 B6 BK2 .
I typed in this one as an example of an asymmetric sett.

View File

@ -1,13 +0,0 @@
Name: Colorado
Sett: Y4 R6 (669)34 K40 G4 W6 LV6 W6 G22
Wikipedia lists the sett as `[Y/6] R4 MB26 K32 G4 W4 Lv4 W4 [G/44]`. I'm
not familiar with the [Color/Count] notation, the count appears to be
doubled, possibly to indicate the total count of that thread in the
mirror section.
[Colorado house joint resolution
97-1016](http://www.state.co.us/gov_dir/leg_dir/res/HJR1016.htm) makes
this official but doesn't provide a thread count. It speaks of
"cerulean blue" which I approximate with the unique (669) color.

View File

@ -1,40 +0,0 @@
#! /usr/bin/python
import cgitb; cgitb.enable()
import loom
import cgi
import urllib.request, urllib.parse, urllib.error
import os
import sys
os.chdir("/home/neale/public_html/tartans")
f = cgi.FieldStorage()
s = f.getfirst('sett')
if s:
print('Content-type: image/png')
print('')
sett = loom.str_to_sett(s)
l = loom.tartan(sett)
l.png(sys.stdout)
else:
t = f.getfirst('t', 'Unknown')
s = f.getfirst('s')
if not t or not s:
# Default to Black Watch
t = 'Black Watch'
s = ('B22 BK2 B2 BK2 B2 BK16 G16 BK2 G16 BK16 B16 BK2 B2 '
'BK2 G10 BK8 DB9 BK1 DB1')
s_ = s.replace(' ', '').replace('\n', '')
print('Content-type: text/html')
print('')
sys.stdout.flush()
content = ('Name: %s\nSett: %s\n' % (t, s))
png = 'design.cgi?sett=%s' % urllib.parse.quote(s_)
cvt = os.popen('./tartantomdwn %s tartan.m4 | ../mdwntohtml ../template.m4' % (png,),
'w')
cvt.write(content)
cvt.close()

View File

@ -1,4 +0,0 @@
Name: The Hacker
Sett: G1 LG3 G3 K7
Created by pi-rho, an impressive hacker in his own right.

View File

@ -1,23 +0,0 @@
Title: Tartans
I like tartans, they appeal to my geeky need for symmetry and elegant
description.
<div class="figure">
<img src="nmloe.png" alt="tartan image" />
<br />
<a href="nmloe.html">
New Mexico Land Of Enchantment
</a>
<br />
LG8 LV32 R4 G32 LG32 Y4 LG4
</div>
I've written a [tartan designer](design.cgi) that will take a sett
pattern in modified xtartan format, and output a PNG image of said
tartan. Below are some tartans I've made with it.
If you have one you'd like to contribute to my database, or would like
the code that generates this stuff, feel free to [email
me](mailto:neale-tartan@woozle.org).

16
tartans/index.mdwn Normal file
View File

@ -0,0 +1,16 @@
Title: Tartans
Header: <script src="tartans.js"></script>
<canvas id="loom" width="600" height="300">
Sorry, you need HTML5 and JavaScript for this.
</canvas>
Sett: <input id="sett" value="LG8 LV32 R4 G32 LG32 Y4 LG4" size="30">
Weight: <input id="thick" type="number" value="2" min="1" max="10" size="1">
Preset: <select id="preset"><option>---</option></select>
<p id="desc"></p>
If you have one you'd like to contribute to my database, or would like the code that generates this stuff, feel free to email me.

View File

@ -1,154 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>loom</title>
<script type="application/javascript">
function Yarn(r, g, b) {
var rgb = [Math.round(r*255), Math.round(g*255), Math.round(b*255)]
return "rgb(" + rgb.join(",") + ")"
}
var colors = {
"R": Yarn(0.50, 0.00, 0.00), // Red
"G": Yarn(0.00, 0.40, 0.00), // Green
"B": Yarn(0.00, 0.00, 0.50), // Blue
"C": Yarn(0.00, 0.50, 0.50), // Cyan
"Y": Yarn(0.80, 0.80, 0.00), // Yellow
"P": Yarn(0.60, 0.00, 0.60), // Purple
"W": Yarn(0.90, 0.90, 0.90), // White
"K": Yarn(0.00, 0.00, 0.00), // Black
"BK": Yarn(0.00, 0.00, 0.00), // Black
"GR": Yarn(0.50, 0.50, 0.50), // Gray
"DB": Yarn(0.00, 0.00, 0.30), // Dark Blue
"LB": Yarn(0.00, 0.40, 0.90), // Light Blue
"LR": Yarn(0.80, 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.60, 0.40, 0.20), // Brown
"LGR": Yarn(0.60, 0.60, 0.60), // Light Gray
"LBR": Yarn(0.80, 0.70, 0.50), // Light Brown
"": ""
}
function Loom(ctx, warp) {
ctx.lineWidth = 3;
for (var x in warp) {
var yarn = warp[x];
ctx.strokeStyle = yarn;
ctx.beginPath();
ctx.moveTo(x*ctx.lineWidth, 0);
ctx.lineTo(x*ctx.lineWidth, 600);
ctx.stroke();
}
this.nrows = 0;
this.warp = warp;
this.weave = function(yarn, up, down, skip, repeat) {
up = up || 1
down = down || 1
skip = skip || 0
repeat = repeat || 0
ctx.strokeStyle = yarn;
var offset = (this.nrows / (repeat + 1)) * (skip + 1);
var harness = up + down;
var row = [];
for (var x = 0; x < this.warp.length; x += 1) {
var ox = (x + offset) % harness
if (ox < up) {
ctx.beginPath();
ctx.moveTo(x*ctx.lineWidth, this.nrows*ctx.lineWidth);
ctx.lineTo((x+1)*ctx.lineWidth, this.nrows*ctx.lineWidth);
ctx.stroke();
}
}
this.nrows += 1;
}
this.plainWeave = function(yarn) {
this.weave(yarn);
}
this.twill = function(yarn, width) {
this.weave(yarn, width || 2, width || 2);
}
this.satinWeave = function(yarn) {
// 1/16, skip 4
this.weave(yarn, 1, 16, 4);
}
this.basketWeave = function(yarn) {
// 2/2, skip 1, repeat 1
this.weave(yarn, 2, 2, 1, 1);
}
this.plaid = function() {
for (var i in this.warp) {
this.twill(this.warp[i]);
}
}
}
var sett_re = /([A-Za-z]{1,3}|\([A-Fa-f0-9]{3}\))(\d{1,3})/;
function settOfString(str) {
var sett = []
while (str.length > 0) {
var result = sett_re.exec(str);
if (result == null) {
break
}
var color;
var cs = result[1];
if (cs[0] == "(") {
color = "#" + cs.substr(1, cs.length-2);
} else {
color = colors[cs];
}
for (var i = 0; i < result[2]; i += 1) {
sett.push(color);
}
str = str.substr(result[0].length + result.index);
}
if (str[str.length - 1] == ".") {
var ttes = sett.reverse();
sett = sett.concat(ttes);
}
if (sett.length % 4 != 0) {
sett = sett.concat(sett);
}
return sett;
}
function weave(pattern) {
var canvas = document.getElementById("loom");
var ctx = canvas.getContext("2d");
var sett = settOfString(pattern);
var l = new Loom(ctx, sett);
l.plaid();
}
function krang() {
weave("LG8 LV32 R4 G32 LG32 Y4 LG4");
}
window.onload = krang;
</script>
</head>
<body>
<h1>Loom</h1>
<canvas id="loom" width="600" height="600">
Sorry, you need HTML5 and JavaScript for this.
</canvas>
</body>
</html>

View File

@ -1,204 +0,0 @@
#! /usr/bin/python
# coding: utf-8
import re
import random
class Yarn:
"""A spool of yarn.
Color is specified as a 3-tuple (red, green, blue) of
saturation values ranging from 0.0 (no saturation) to
1.0 (full saturation).
Since we're pretending to be actual dyes here, we can fuzz it out a
bit by not doing full screen saturation and adding a little bit of
randomness to the color when queried.
"""
maxval = 190
fuzz = 0
def __init__(self, r, g, b):
self.rgb = (r, g, b)
self.intrgb = [int(c * self.maxval) for c in self.rgb]
intfuzz = int(self.fuzz * self.maxval)
self.limits = [(max(0, c - intfuzz), min(self.maxval, c + intfuzz))
for c in self.intrgb]
def __repr__(self):
return '<Yarn %r>' % (self.rgb)
def get_color(self):
if self.fuzz:
color = [random.randrange(l, h) for (l, h) in self.limits]
return color
else:
return self.intrgb
class Loom:
def __init__(self, warp):
self.warp = warp
self.fabric = []
def weave(self, yarn, up=1, down=1, skip=0, repeat=0):
offset = (len(self.fabric) / (repeat + 1)) * (skip + 1)
harnesses = up + down
row = []
for i in range(len(self.warp)):
j = (i + offset) % harnesses
if j < down:
row.append(self.warp[i])
else:
row.append(yarn)
self.fabric.append(row)
def plain_weave(self, yarn):
# AKA tabby weave, taffeta weave
self.weave(yarn)
def twill(self, yarn, up=2, down=2):
self.weave(yarn, up, down)
def satin_weave(self, yarn):
# 1/16, skip 4
self.weave(yarn, 1, 16, 4)
def basket_weave(self, yarn):
# 2/2, skip 1, repeat 1
self.weave(yarn, 2, 2, 1, 1)
class PNGLoom(Loom):
def png(self, outf, scale=1):
import Image
import array
imgstr = array.array('B')
for fr in self.fabric:
row = []
for c in fr:
for i in range(scale):
row.extend(c.get_color())
for i in range(scale):
imgstr.fromlist(row)
x = len(fr * scale)
y = len(self.fabric * scale)
img = Image.fromstring('RGB', (x, y), imgstr.tostring())
img.save(outf, 'PNG')
def ascii_test():
print('Plain weave')
l = Loom('||||||||||||||||||||||||||||||||')
for i in range(16):
l.plain_weave('-')
for row in l.fabric:
print(' ', ''.join(row))
print('Twill')
l = Loom('||||||||||||||||||||||||||||||||')
for i in range(16):
l.twill('-')
for row in l.fabric:
print(' ', ''.join(row))
print('2/1 twill')
l = Loom('||||||||||||||||||||||||||||||||')
for i in range(16):
l.twill('-', 2, 1)
for row in l.fabric:
print(' ', ''.join(row))
print('Satin weave')
l = Loom('||||||||||||||||||||||||||||||||')
for i in range(16):
l.satin_weave('-')
for row in l.fabric:
print(' ', ''.join(row))
print('Basketweave')
l = Loom('||||||||||||||||||||||||||||||||')
for i in range(16):
l.basket_weave('-')
for row in l.fabric:
print(' ', ''.join(row))
##
## Tartan junk
##
#
# Colors according to http://www.tartanregister.gov.uk/guidance.aspx
#
colors = {'R': Yarn(0.50, 0.00, 0.00), # Red
'G': Yarn(0.00, 0.40, 0.00), # Green
'B': Yarn(0.00, 0.00, 0.50), # Blue
'C': Yarn(0.00, 0.50, 0.50), # Cyan
'Y': Yarn(0.80, 0.80, 0.00), # Yellow
'P': Yarn(0.60, 0.00, 0.60), # Purple
'W': Yarn(0.90, 0.90, 0.90), # White
'K': Yarn(0.00, 0.00, 0.00), # Black
'BK': Yarn(0.00, 0.00, 0.00), # Black
'GR': Yarn(0.50, 0.50, 0.50), # Gray
'DB': Yarn(0.00, 0.00, 0.30), # Dark Blue
'LB': Yarn(0.00, 0.40, 0.90), # Light Blue
'LR': Yarn(0.80, 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.60, 0.40, 0.20), # Brown
'LGR': Yarn(0.60, 0.60, 0.60), # Light Gray
'LBR': Yarn(0.80, 0.70, 0.50), # 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 = []
for a in cs[1:-1]:
ca.append(int(a+a, 16) / 256.0)
y = Yarn(*ca)
else:
y = colors[cs]
for i in range(int(m.group(2))):
sett.append(y)
s = s[m.end():]
if not s.endswith('.'):
o = sett[:]
o.reverse()
sett += o
if len(sett) % 4:
sett += sett
return sett
def tartan(sett):
l = PNGLoom(sett)
for y in sett:
l.twill(y)
return l
if __name__ == '__main__':
import sys
for line in sys.stdin:
if line.startswith('Sett:'):
_, s = line.split(':', 1)
s = s.strip()
break
sett = str_to_sett(s)
l = tartan(sett)
l.png(sys.stdout, 1)

View File

@ -1,9 +0,0 @@
#! /bin/sh
cat $1; shift
for i in "$@"; do
base=$(basename $i .tartan)
name=$(awk -F': ' '(/^Name:/) {print $2; exit;}' $i)
echo "* [$name]($base.html)"
done

Binary file not shown.

Before

Width:  |  Height:  |  Size: 147 KiB

View File

@ -1,10 +0,0 @@
Name: New Mexico
Sett: R4 G24 B4 G16 B36 Y8 R4 Y4
Designed by Ralph Stevenson Jr, [officially recognized in 2003](nm-proc.png)
by the Secretary of State. It is similar in design to the [Albuquerque
tartan](albuquerque.html). I bought a scarf of this plaid from
Mr. Stevenson; it came with a photocopy of the tartan registration and a
few other documents.
[Bally Dun Celtic Treasures](http://www.ballydun.com/) sells this tartan.

View File

@ -1,7 +0,0 @@
Name: New Mexico Land Of Enchantment
Sett: LG8 LV32 R4 G32 LG32 Y4 LG4
This isn't official but I think it's pretty. I just guessed at the
sett pattern but I think I got pretty close.
[Kathy Lare](http://www.kathyskilts.com/) is the sole source for this
fabric.

View File

@ -1,6 +0,0 @@
Name: Nevada
Sett: W4 LGR16 B4 LGR8 B8 Y4 B4 R4 B20
Based on a terrible gif that is apparently a part of [Nevada Revised
Statute 235.130](http://leg.state.nv.us/NRS/NRS-235.html#NRS235Sec130).
Designed by Richard Zygmunt Pawlowski, approved May 8, 2001.

View File

@ -1,4 +0,0 @@
Name: Oklahoma
Sett: R4 W8 LB64 Y6 BK16
Based on a photo on a web page.

View File

@ -1,11 +0,0 @@
Name: Oregon
Sett: Y3 LV10 G4 LV4 G4 W2 G8 LBR24 R4 LB2 K2
I had to reverse-engineer this from the UK tartan registry. If you
create an account with them, and request a sett, they'll email up to 5
per day to you. I don't understand why a state's official tartan should
be so difficult to obtain: it seems like it ought to belong to the
people of that state and be easily accessed by them.
Well, here you go, people of Oregon.

View File

@ -1,7 +0,0 @@
Name: Neale's PJs
Sett: W7 C3 GR5 BK3 C5 BK3 C6 GR3 C5
This is an approximation of the pajamas I was wearing when I wrote the
tartan designer. They weren't actually a tartan. I guess modern
weavers feel they ought to show off the fact that they can do fancy
tricks with their looms.

View File

@ -1,5 +0,0 @@
Name: Neale's PJs II
Sett: W3 G24 Y2 W2 G2 W2 G2 W1
More of my PJs. This one is an exact copy, I can count the threads
in this fabric.

View File

@ -1,6 +0,0 @@
Name: Shrek
Sett: LBR4 BR8 G16 R2 G16 BR32
I (Neale) created this based on Shrek's pants in a couple of frame grabs
from the movie. It appears to be different from the recently-released
"Shrek's Tartan".

View File

@ -1,24 +0,0 @@
Title: TARTAN Tartan
<div style="background: url(IMAGE);
height: 300px;
border: solid black 10px;
clear: both;">
</div>
<p><a href="IMAGE">This image</a></p>
divert(1)
I place this image in the public domain, in the hope that it will
increase interest in tartans and tartan design.
<form action="design.cgi">
<fieldset>
<legend>Tartan Designer</legend>
<label for="t">Name:</label> <input name="t" id="t" value="TARTAN" /> <br/>
<label for="s">Sett:</label> <input name="s" id="s" value="SETT" style="width: 90%" /> <br/>
<input type="submit" value="Design" />
</fieldset>
</form>
divert(0)

388
tartans/tartans.js Normal file
View File

@ -0,0 +1,388 @@
// © 2015 Neale Pickett <neale@woozle.org>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// The software is provided "as is", without warranty of any kind, express or
// implied, including but not limited to the warranties of merchantability,
// fitness for a particular purpose and noninfringement. In no event shall the
// authors or copyright holders be liable for any claim, damages or other
// liability, whether in an action of contract, tort or otherwise, arising from,
// out of or in connection with the software or the use or other dealings in
// the software.
//
// TODO: Clear preset when fiddling with sett
// TODO: Make preset part of URL
var tartans = {
"Albuquerque": {
"sett": "R4 G24 B4 G10 B36 W6 R4 W4",
"description": "Created by Ralph Stevenson Jr and Charles Hargis in 2005 for the city's tricentennial anniversary (1706-2006). It is similar in design to the New Mexico tartan, with a little less green, and white instead of yellow, with a thicker center band."
},
"Armstrong": {
"sett": "G4 BK2 G60 BK24 B4 BK2 B2 BK2 B24 R6",
"description": ""
},
"Arizona": {
"sett": "W2 G3 R4 G28 B3 BR8",
"description": "Based on a jpeg I found on a geocities homepage. Surprisingly, that jpeg was the only mention I could find on the net of what the actual sett was for Arizona."
},
"Black Watch": {
"sett": "B22 BK2 B2 BK2 B2 BK16 G16 BK2 G16 BK16 B16 BK2 B2 BK2 G10 BK8 DB9 BK1 DB1",
"description": "A standard."
},
"Buchanan": {
"sett": "Y8 BK2 Y8 BK2 B6 BK2 G8 B4 G8 BK2 B6 BK2 LR10 W2 LR10 BK2 B6 BK2 .",
"description": "I typed in this one as an example of an asymmetric sett."
},
"Colorado": {
"sett": "Y4 R6 (669)34 K40 G4 W6 LV6 W6 G22",
"description": "Wikipedia lists the sett as [Y/6] R4 MB26 K32 G4 W4 Lv4 W4 [G/44]. I'm not familiar with the [Color/Count] notation, the count appears to be doubled, possibly to indicate the total count of that thread in the mirror section.\n\n[Colorado house joint resolution 97-1016](http://www.state.co.us/gov_dir/leg_dir/res/HJR1016.htm) makes this official but doesnt provide a thread count. It speaks of \"cerulean blue\" which I approximate with the unique (669) color."
},
"The Hacker": {
"sett": "G1 LG3 G3 K7",
"description": "Created by pi-rho, an impressive hacker in his own right."
},
"New Mexico": {
"sett": "R4 G24 B4 G16 B36 Y8 R4 Y4",
"description": "Designed by Ralph Stevenson Jr, [officially recognized in 2003](nm-proc.png) by the Secretary of State. It is similar in design to the [Albuquerque tartan](albuquerque.html). I bought a scarf of this plaid from Mr. Stevenson; it came with a photocopy of the tartan registration and a few other documents."
},
"New Mexico Land Of Enchantment": {
"sett": "LG8 LV32 R4 G32 LG32 Y4 LG4",
"description": "This isn't official but I think it's pretty. I just guessed at the sett pattern but I think I got pretty close. [Kathy Lare](http://www.kathyskilts.com/) is the sole source for this fabric."
},
"Nevada": {
"sett": "W4 LGR16 B4 LGR8 B8 Y4 B4 R4 B20",
"description": "Based on a terrible gif that is apparently a part of [Nevada Revised Statute 235.130](http://leg.state.nv.us/NRS/NRS-235.html#NRS235Sec130). Designed by Richard Zygmunt Pawlowski, approved May 8, 2001."
},
"Oklahoma": {
"sett": "R4 W8 LB64 Y6 BK16",
"description": "Based on a photo on a web page."
},
"Oregon": {
"sett": "Y3 LV10 G4 LV4 G4 W2 G8 LBR24 R4 LB2 K2",
"description": "Here you go, people of Oregon: your legislature apparently thought the best way to record your tartan was registering it with a private company."
},
"Neale's PJs": {
"sett": "W7 C3 GR5 BK3 C5 BK3 C6 GR3 C5",
"description": "This is an approximation of the pajamas I was wearing when I wrote the tartan designer. They weren't actually a tartan. I guess modern weavers feel they ought to show off the fact that they can do fancy tricks with their looms."
},
"Neale's PJs II": {
"sett": "W3 G24 Y2 W2 G2 W2 G2 W1",
"description": "More of my PJs. This one is an exact copy, I can count the threads in this fabric."
},
"Shrek": {
"sett": "LBR4 BR8 G16 R2 G16 BR32",
"description": "I (Neale) created this based on Shrek's pants in a couple of frame grabs from the movie. It appears to be different from the recently-released \"Shrek's Tartan\"."
},
"Texas Bluebonnet": {
"sett": "G4 R2 B16 W2 R2 W2 LB16 W2 LB16 W2 Y1",
"description": "Based off a jpeg at the [Texas Scottish Heritage Society](http://www.txscot.com/BB_tartan.htm#bluebonnet). (Why did they save it as a jpeg?) The first blue in their image was only 15 threads wide, I figured that was a typographical mistake given every subsequent blue was 16, even in the repeats. According to the aforementioned web page, it was designed by June Prescott McRoberts, and adopted as the official state tartan on May 25, 1989."
},
"Utah": {
"sett": "W1 B6 R6 B4 R6 G18 R6 W4",
"description": "Kudos to Utah for putting the sett right into 1996's SB-13. This is the tartan as specified by law. The [photograph on Utah's Online Library](http://pioneer.utah.gov/utah_on_the_web/utah_symbols/tartan.html) seems to have a final white threadcount of 3."
},
"Washington State": {
"sett": "W3 R6 B36 G72 LB6 BK6 Y2",
"description": "Adopted 1991 by the spartan [RCW 1.20.110](http://apps.leg.wa.gov/rcw/default.aspx?cite=1.20.110)."
}
}
var maxSaturation = 200;
function Yarn(r, g, b) {
var rgb = [Math.round(r*maxSaturation), Math.round(g*maxSaturation), Math.round(b*maxSaturation)]
return "rgb(" + rgb.join(",") + ")"
}
var colors = {
"R": Yarn(0.50, 0.00, 0.00), // Red
"G": Yarn(0.00, 0.40, 0.00), // Green
"B": Yarn(0.00, 0.00, 0.50), // Blue
"C": Yarn(0.00, 0.50, 0.50), // Cyan
"Y": Yarn(0.80, 0.80, 0.00), // Yellow
"P": Yarn(0.60, 0.00, 0.60), // Purple
"W": Yarn(0.90, 0.90, 0.90), // White
"K": Yarn(0.00, 0.00, 0.00), // Black
"BK": Yarn(0.00, 0.00, 0.00), // Black
"GR": Yarn(0.50, 0.50, 0.50), // Gray
"DB": Yarn(0.00, 0.00, 0.30), // Dark Blue
"LB": Yarn(0.00, 0.40, 0.90), // Light Blue
"LR": Yarn(0.80, 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.60, 0.40, 0.20), // Brown
"LGR": Yarn(0.60, 0.60, 0.60), // Light Gray
"LBR": Yarn(0.80, 0.70, 0.50), // Light Brown
"": ""
}
function Loom(ctx, warp, threadwidth) {
var width = ctx.canvas.width;
var height = ctx.canvas.height;
ctx.lineWidth = Number(threadwidth || 2);
// Draw the weft
for (var x = 0; x < width; ) {
for (var i in warp) {
ctx.strokeStyle = warp[i];
ctx.beginPath();
ctx.moveTo(x, 0);
ctx.lineTo(x, height);
ctx.stroke();
x += ctx.lineWidth;
if (x > width) {
break;
}
}
}
this.nrows = 0;
this.weave = function(yarn, up, down, skip, repeat) {
up = up || 1
down = down || 1
skip = skip || 0
repeat = repeat || 0
ctx.strokeStyle = yarn;
var offset = (this.nrows / (repeat + 1)) * (skip + 1);
var harness = up + down;
var row = [];
for (var i = 0; i*ctx.lineWidth < width; i += 1) {
var ox = (i + offset) % harness
if (ox < up) {
ctx.beginPath();
ctx.moveTo(i*ctx.lineWidth, this.nrows*ctx.lineWidth);
ctx.lineTo((i+1)*ctx.lineWidth, this.nrows*ctx.lineWidth);
ctx.stroke();
}
}
this.nrows += 1;
}
this.plainWeave = function(yarn) {
this.weave(yarn);
}
this.twill = function(yarn, width) {
this.weave(yarn, width || 2, width || 2);
}
this.satinWeave = function(yarn) {
// 1/16, skip 4
this.weave(yarn, 1, 16, 4);
}
this.basketWeave = function(yarn) {
// 2/2, skip 1, repeat 1
this.weave(yarn, 2, 2, 1, 1);
}
this.plaid = function() {
for (var i = 0; i*ctx.lineWidth < height; i += 1) {
var j = i % warp.length;
this.twill(warp[j]);
}
}
}
var sett_re = /([A-Za-z]{1,3}|\([A-Fa-f0-9]{3}\))(\d{1,3})/;
function settOfString(str) {
var sett = []
while (str.length > 0) {
var result = sett_re.exec(str);
if (result == null) {
break
}
var color;
var cs = result[1];
if (cs[0] == "(") {
color = "#" + cs.substr(1, cs.length-2);
} else {
color = colors[cs];
}
for (var i = 0; i < result[2]; i += 1) {
sett.push(color);
}
str = str.substr(result[0].length + result.index);
}
if (str[str.length - 1] != ".") {
var ttes = sett.concat();
ttes.reverse();
sett = sett.concat(ttes);
}
if (sett.length % 4 != 0) {
sett = sett.concat(sett);
}
return sett;
}
function weave(pattern, width) {
var canvas = document.getElementById("loom");
var ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
var sett = settOfString(pattern);
var l = new Loom(ctx, sett, width);
l.plaid();
}
function update(e) {
var settInput = document.getElementById("sett");
var thickInput = document.getElementById("thick");
weave(settInput.value, thick.value);
var s = encodeURIComponent(settInput.value).replace(/%20/g, "+");
window.location.hash = "s=" + s + "&w=" + thickInput.value;
}
var tartans = {
"Albuquerque": {
"sett": "R4 G24 B4 G10 B36 W6 R4 W4",
"description": "Created by Ralph Stevenson Jr and Charles Hargis in 2005 for the city's tricentennial anniversary (1706-2006). It is similar in design to the New Mexico tartan, with a little less green, and white instead of yellow, with a thicker center band."
},
"Armstrong": {
"sett": "G4 BK2 G60 BK24 B4 BK2 B2 BK2 B24 R6",
"description": ""
},
"Arizona": {
"sett": "W2 G3 R4 G28 B3 BR8",
"description": "Based on a jpeg I found on a geocities homepage. Surprisingly, that jpeg was the only mention I could find on the net of what the actual sett was for Arizona."
},
"Black Watch": {
"sett": "B22 BK2 B2 BK2 B2 BK16 G16 BK2 G16 BK16 B16 BK2 B2 BK2 G10 BK8 DB9 BK1 DB1",
"description": "A standard."
},
"Buchanan": {
"sett": "Y8 BK2 Y8 BK2 B6 BK2 G8 B4 G8 BK2 B6 BK2 LR10 W2 LR10 BK2 B6 BK2 .",
"description": "I typed in this one as an example of an asymmetric sett."
},
"Colorado": {
"sett": "Y4 R6 (669)34 K40 G4 W6 LV6 W6 G22",
"description": "Wikipedia lists the sett as [Y/6] R4 MB26 K32 G4 W4 Lv4 W4 [G/44]. I'm not familiar with the [Color/Count] notation, the count appears to be doubled, possibly to indicate the total count of that thread in the mirror section.\n\n[Colorado house joint resolution 97-1016](http://www.state.co.us/gov_dir/leg_dir/res/HJR1016.htm) makes this official but doesnt provide a thread count. It speaks of \"cerulean blue\" which I approximate with the unique (669) color."
},
"The Hacker": {
"sett": "G1 LG3 G3 K7",
"description": "Created by pi-rho, an impressive hacker in his own right."
},
"New Mexico": {
"sett": "R4 G24 B4 G16 B36 Y8 R4 Y4",
"description": "Designed by Ralph Stevenson Jr, [officially recognized in 2003](nm-proc.png) by the Secretary of State. It is similar in design to the [Albuquerque tartan](albuquerque.html). I bought a scarf of this plaid from Mr. Stevenson; it came with a photocopy of the tartan registration and a few other documents."
},
"New Mexico Land Of Enchantment": {
"sett": "LG8 LV32 R4 G32 LG32 Y4 LG4",
"description": "This isn't official but I think it's pretty. I just guessed at the sett pattern but I think I got pretty close. [Kathy Lare](http://www.kathyskilts.com/) is the sole source for this fabric."
},
"Nevada": {
"sett": "W4 LGR16 B4 LGR8 B8 Y4 B4 R4 B20",
"description": "Based on a terrible gif that is apparently a part of [Nevada Revised Statute 235.130](http://leg.state.nv.us/NRS/NRS-235.html#NRS235Sec130). Designed by Richard Zygmunt Pawlowski, approved May 8, 2001."
},
"Oklahoma": {
"sett": "R4 W8 LB64 Y6 BK16",
"description": "Based on a photo on a web page."
},
"Oregon": {
"sett": "Y3 LV10 G4 LV4 G4 W2 G8 LBR24 R4 LB2 K2",
"description": "Here you go, people of Oregon: your legislature apparently thought the best way to record your tartan was registering it with a private company."
},
"Neale's PJs": {
"sett": "W7 C3 GR5 BK3 C5 BK3 C6 GR3 C5",
"description": "This is an approximation of the pajamas I was wearing when I wrote the tartan designer. They weren't actually a tartan. I guess modern weavers feel they ought to show off the fact that they can do fancy tricks with their looms."
},
"Neale's PJs II": {
"sett": "W3 G24 Y2 W2 G2 W2 G2 W1",
"description": "More of my PJs. This one is an exact copy, I can count the threads in this fabric."
},
"Shrek": {
"sett": "LBR4 BR8 G16 R2 G16 BR32",
"description": "I (Neale) created this based on Shrek's pants in a couple of frame grabs from the movie. It appears to be different from the recently-released \"Shrek's Tartan\"."
},
"Texas Bluebonnet": {
"sett": "G4 R2 B16 W2 R2 W2 LB16 W2 LB16 W2 Y1",
"description": "Based off a jpeg at the [Texas Scottish Heritage Society](http://www.txscot.com/BB_tartan.htm#bluebonnet). (Why did they save it as a jpeg?) The first blue in their image was only 15 threads wide, I figured that was a typographical mistake given every subsequent blue was 16, even in the repeats. According to the aforementioned web page, it was designed by June Prescott McRoberts, and adopted as the official state tartan on May 25, 1989."
},
"Utah": {
"sett": "W1 B6 R6 B4 R6 G18 R6 W4",
"description": "Kudos to Utah for putting the sett right into 1996's SB-13. This is the tartan as specified by law. The [photograph on Utah's Online Library](http://pioneer.utah.gov/utah_on_the_web/utah_symbols/tartan.html) seems to have a final white threadcount of 3."
},
"Washington State": {
"sett": "W3 R6 B36 G72 LB6 BK6 Y2",
"description": "Adopted 1991 by the spartan [RCW 1.20.110](http://apps.leg.wa.gov/rcw/default.aspx?cite=1.20.110)."
}
}
function preset() {
var presetName = document.getElementById("preset").value;
var tartan = tartans[presetName];
if (! tartan) {
tartan = tartans["Black Watch"];
}
document.getElementById("sett").value = tartan["sett"];
document.getElementById("desc").innerText = tartan["description"];
update();
}
var qs = (function(a) {
if (a == "") return {};
var b = {};
for (var i = 0; i < a.length; ++i)
{
var p=a[i].split('=', 2);
if (p.length == 1)
b[p[0]] = "";
else
b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
}
return b;
})(window.location.hash.split('&'));
function init() {
document.getElementById("sett").addEventListener("input", update);
document.getElementById("thick").addEventListener("input", update);
if (qs["s"]) {
document.getElementById("sett").value = qs["s"];
}
if (qs["w"]) {
document.getElementById("thick").value = qs["w"];
}
var presetInput = document.getElementById("preset")
presetInput.addEventListener("change", preset);
for (var name in tartans) {
var opt = document.createElement("option");
opt.value = name;
opt.text = name;
presetInput.appendChild(opt);
}
preset();
}
window.addEventListener("load", init);

View File

@ -1,23 +0,0 @@
TARTAN_TEMPLATE = tartans/tartan.m4
TARTAN_LIST = $(wildcard tartans/*.tartan)
TARTAN_PNG = $(patsubst %.tartan, %.png, $(TARTAN_LIST))
TARTAN_TOMDWN = tartans/tartantomdwn
COPY += tartans/design.cgi tartans/loom.py $(TARTAN_TOMDWN) $(TARTAN_TEMPLATE)
COPY += tartans/nm-proc.png
HTML += tartans/index.html
HTML += $(patsubst %.tartan, %.html, $(TARTAN_LIST))
TARGETS += $(addprefix $(DESTDIR)/, $(TARTAN_PNG))
$(DESTDIR)/tartans/%.html: tartans/%.tartan $(TARTAN_TEMPLATE)
@mkdir -p $(@D)
$(TARTAN_TOMDWN) $*.png $(TARTAN_TEMPLATE) < $< | $(MDWNTOHTML) > $@
$(DESTDIR)/tartans/%.png: tartans/%.tartan
@mkdir -p $(@D)
tartans/loom.py < $< > $@
$(DESTDIR)/tartans/index.html: tartans/index.head.mdwn $(wildcard tartans/*.tartan)
@mkdir -p $(@D)
cp $(wordlist 2, $(words $^), $^) $(@D)
tartans/lstartans $+ | $(MDWNTOHTML) > $@

View File

@ -1,19 +0,0 @@
#! /bin/sh
while IFS=: read key val; do
tval=$(echo $val | sed "s/'/\&apos;/g")
case $key in
Name)
tartan="$tval"
;;
Sett)
sett="$tval"
;;
"")
break
;;
esac
done
m4 -DTARTAN="$tartan" -DSETT="$sett" -DIMAGE="$1" $2 -

View File

@ -1,12 +0,0 @@
Name: Texas Bluebonnet
Sett: G4 R2 B16 W2 R2 W2 LB16 W2 LB16 W2 Y1
Based off a jpeg at the [Texas Scottish Heritage
Society](http://www.txscot.com/BB_tartan.htm#bluebonnet). (Why did they
save it as a jpeg?) The first blue in their image was only 15 threads
wide, I figured that was a typographical mistake given every subsequent
blue was 16, even in the repeats.
According to the aforementioned web page, it was designed by June
Prescott McRoberts, and adopted as the official state tartan on May 25,
1989.

View File

@ -1,7 +0,0 @@
Name: Utah
Sett: W1 B6 R6 B4 R6 G18 R6 W4
Kudos to Utah for putting the sett right into 1996's SB-13. This is the
tartan as specified by law. The [photograph on Utah's Online
Library](http://pioneer.utah.gov/utah_on_the_web/utah_symbols/tartan.html)
seems to have a final white threadcount of 3.

View File

@ -1,5 +0,0 @@
Name: Washington State
Sett: W3 R6 B36 G72 LB6 BK6 Y2
Adopted 1991 by the spartan [RCW
1.20.110](http://apps.leg.wa.gov/rcw/default.aspx?cite=1.20.110).

View File

@ -1,9 +0,0 @@
<head>
<title>TITLE</title>
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" type="text/css" href="/neale/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" media="screen" href="/neale/css/default.css">
<link rel="stylesheet" type="text/css" media="print" href="/neale/css/print.css">
<link rel="icon" type="image/png" href="/neale/face.png">
<link rel="start" type="text/html" href="/neale/" title="Neale Pickett Page">
</head>

View File

@ -1,23 +1,43 @@
#! /bin/sh
while IFS=: read field value; do
cat <<EOD
<!DOCTYPE html>
<html lang="en">
<head>
EOD
while IFS=': ' read field value; do
case "$field" in
"")
break
;;
Title)
# echo strips leading and trailing whitespace
title=${value# }
title=$value
;;
Header)
printf " %s\n" "$value"
;;
esac
done
tmpl=$(dirname $0)
printf '<!DOCTYPE html>\n'
printf '<html lang="en">\n'
sed "s~TITLE~$title~" $tmpl/head.tmpl
printf "<body><h1>%s</h1>\n" "$title"
cat <<EOD
<title>$title</title>
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" type="text/css" href="/neale/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" media="screen" href="/neale/css/default.css">
<link rel="stylesheet" type="text/css" media="print" href="/neale/css/print.css">
<link rel="icon" type="image/png" href="/neale/face.png">
</head>
<body>
<h1>$title</h1>
EOD
cat $tmpl/head.tmpl
markdown
cat $tmpl/foot.tmpl
printf '</body></html>\n'
cat <<EOD
</body>
</html>
EOD