diff --git a/tartans/albuquerque.tartan b/tartans/albuquerque.tartan deleted file mode 100644 index 210ef52..0000000 --- a/tartans/albuquerque.tartan +++ /dev/null @@ -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. diff --git a/tartans/armstrong.tartan b/tartans/armstrong.tartan deleted file mode 100644 index 96c7811..0000000 --- a/tartans/armstrong.tartan +++ /dev/null @@ -1,2 +0,0 @@ -Name: Armstrong -Sett: G4 BK2 G60 BK24 B4 BK2 B2 BK2 B24 R6 diff --git a/tartans/az.tartan b/tartans/az.tartan deleted file mode 100644 index 318553d..0000000 --- a/tartans/az.tartan +++ /dev/null @@ -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. diff --git a/tartans/blackwatch.tartan b/tartans/blackwatch.tartan deleted file mode 100644 index 75f8ed0..0000000 --- a/tartans/blackwatch.tartan +++ /dev/null @@ -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. diff --git a/tartans/buchanan.tartan b/tartans/buchanan.tartan deleted file mode 100644 index 2963ffa..0000000 --- a/tartans/buchanan.tartan +++ /dev/null @@ -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. diff --git a/tartans/co.tartan b/tartans/co.tartan deleted file mode 100644 index c7033cb..0000000 --- a/tartans/co.tartan +++ /dev/null @@ -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. - diff --git a/tartans/design.cgi b/tartans/design.cgi deleted file mode 100755 index fdba178..0000000 --- a/tartans/design.cgi +++ /dev/null @@ -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() diff --git a/tartans/hacker.tartan b/tartans/hacker.tartan deleted file mode 100644 index 17a556a..0000000 --- a/tartans/hacker.tartan +++ /dev/null @@ -1,4 +0,0 @@ -Name: The Hacker -Sett: G1 LG3 G3 K7 - -Created by pi-rho, an impressive hacker in his own right. diff --git a/tartans/index.head.mdwn b/tartans/index.head.mdwn deleted file mode 100644 index 66a2947..0000000 --- a/tartans/index.head.mdwn +++ /dev/null @@ -1,23 +0,0 @@ -Title: Tartans - -I like tartans, they appeal to my geeky need for symmetry and elegant -description. - -
- tartan image -
- - New Mexico Land Of Enchantment - -
- LG8 LV32 R4 G32 LG32 Y4 LG4 -
- -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). - diff --git a/tartans/index.mdwn b/tartans/index.mdwn new file mode 100644 index 0000000..94554ca --- /dev/null +++ b/tartans/index.mdwn @@ -0,0 +1,16 @@ +Title: Tartans +Header: + + + Sorry, you need HTML5 and JavaScript for this. + + +Sett: +Weight: + +Preset: + +

+ +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. + diff --git a/tartans/loom.html b/tartans/loom.html deleted file mode 100644 index 46c5890..0000000 --- a/tartans/loom.html +++ /dev/null @@ -1,154 +0,0 @@ - - - - loom - - - -

Loom

- - Sorry, you need HTML5 and JavaScript for this. - - - diff --git a/tartans/loom.py b/tartans/loom.py deleted file mode 100755 index e317656..0000000 --- a/tartans/loom.py +++ /dev/null @@ -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 '' % (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) diff --git a/tartans/lstartans b/tartans/lstartans deleted file mode 100755 index 6abd656..0000000 --- a/tartans/lstartans +++ /dev/null @@ -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 diff --git a/tartans/nm-proc.png b/tartans/nm-proc.png deleted file mode 100644 index e4d6896..0000000 Binary files a/tartans/nm-proc.png and /dev/null differ diff --git a/tartans/nm.tartan b/tartans/nm.tartan deleted file mode 100644 index 9815b31..0000000 --- a/tartans/nm.tartan +++ /dev/null @@ -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. diff --git a/tartans/nmloe.tartan b/tartans/nmloe.tartan deleted file mode 100644 index 7246afb..0000000 --- a/tartans/nmloe.tartan +++ /dev/null @@ -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. diff --git a/tartans/nv.tartan b/tartans/nv.tartan deleted file mode 100644 index 9aaf44e..0000000 --- a/tartans/nv.tartan +++ /dev/null @@ -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. diff --git a/tartans/ok.tartan b/tartans/ok.tartan deleted file mode 100644 index 7c28ef6..0000000 --- a/tartans/ok.tartan +++ /dev/null @@ -1,4 +0,0 @@ -Name: Oklahoma -Sett: R4 W8 LB64 Y6 BK16 - -Based on a photo on a web page. diff --git a/tartans/or.tartan b/tartans/or.tartan deleted file mode 100644 index 4886a4d..0000000 --- a/tartans/or.tartan +++ /dev/null @@ -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. - diff --git a/tartans/pjs.tartan b/tartans/pjs.tartan deleted file mode 100644 index 07811c7..0000000 --- a/tartans/pjs.tartan +++ /dev/null @@ -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. diff --git a/tartans/pjs2.tartan b/tartans/pjs2.tartan deleted file mode 100644 index 37e554e..0000000 --- a/tartans/pjs2.tartan +++ /dev/null @@ -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. diff --git a/tartans/shrek.tartan b/tartans/shrek.tartan deleted file mode 100644 index beeaf20..0000000 --- a/tartans/shrek.tartan +++ /dev/null @@ -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". diff --git a/tartans/tartan.m4 b/tartans/tartan.m4 deleted file mode 100644 index a5ae7be..0000000 --- a/tartans/tartan.m4 +++ /dev/null @@ -1,24 +0,0 @@ -Title: TARTAN Tartan - -
-
- -

This image

- -divert(1) - -I place this image in the public domain, in the hope that it will -increase interest in tartans and tartan design. - -
-
- Tartan Designer -
-
- -
-
-divert(0) diff --git a/tartans/tartans.js b/tartans/tartans.js new file mode 100644 index 0000000..064d267 --- /dev/null +++ b/tartans/tartans.js @@ -0,0 +1,388 @@ +// © 2015 Neale Pickett +// +// 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); + diff --git a/tartans/tartans.mk b/tartans/tartans.mk deleted file mode 100644 index 20c895d..0000000 --- a/tartans/tartans.mk +++ /dev/null @@ -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) > $@ diff --git a/tartans/tartantomdwn b/tartans/tartantomdwn deleted file mode 100755 index 19f13b8..0000000 --- a/tartans/tartantomdwn +++ /dev/null @@ -1,19 +0,0 @@ -#! /bin/sh - -while IFS=: read key val; do - tval=$(echo $val | sed "s/'/\'/g") - case $key in - Name) - tartan="$tval" - ;; - Sett) - sett="$tval" - ;; - "") - break - ;; - esac -done - -m4 -DTARTAN="$tartan" -DSETT="$sett" -DIMAGE="$1" $2 - - diff --git a/tartans/tx.tartan b/tartans/tx.tartan deleted file mode 100644 index 4ac7243..0000000 --- a/tartans/tx.tartan +++ /dev/null @@ -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. diff --git a/tartans/ut.tartan b/tartans/ut.tartan deleted file mode 100644 index 6f3f303..0000000 --- a/tartans/ut.tartan +++ /dev/null @@ -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. diff --git a/tartans/wa.tartan b/tartans/wa.tartan deleted file mode 100644 index 685c0ab..0000000 --- a/tartans/wa.tartan +++ /dev/null @@ -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). diff --git a/tmpl/head.tmpl b/tmpl/head.tmpl index b1fb859..e69de29 100644 --- a/tmpl/head.tmpl +++ b/tmpl/head.tmpl @@ -1,9 +0,0 @@ - - TITLE - - - - - - - diff --git a/tmpl/mdwntohtml b/tmpl/mdwntohtml index c2d9827..b96251a 100755 --- a/tmpl/mdwntohtml +++ b/tmpl/mdwntohtml @@ -1,23 +1,43 @@ #! /bin/sh -while IFS=: read field value; do +cat < + + +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 '\n' -printf '\n' -sed "s~TITLE~$title~" $tmpl/head.tmpl -printf "

%s

\n" "$title" +cat <$title + + + + + + + +

$title

+EOD +cat $tmpl/head.tmpl markdown cat $tmpl/foot.tmpl -printf '\n' +cat < + +EOD