Add oregon tartan, mute colors a bit

This commit is contained in:
Neale Pickett 2010-05-28 13:34:16 -05:00
parent f3f965b60b
commit fdea32da36
4 changed files with 55 additions and 36 deletions

View File

@ -47,4 +47,4 @@ actions TartanToPng {
} }
Webify index.mdwn ; Webify index.mdwn ;
Tartan albuquerque armstrong az blackwatch buchanan co nm nmloe nv ok pjs pjs2 shrek tx ut wa ; Tartan albuquerque armstrong az blackwatch buchanan co nm nmloe nv ok pjs pjs2 shrek tx ut wa or ;

View File

@ -2,6 +2,7 @@
# coding: utf-8 # coding: utf-8
import re import re
import random
class Yarn: class Yarn:
"""A spool of yarn. """A spool of yarn.
@ -10,15 +11,32 @@ class Yarn:
saturation values ranging from 0.0 (no saturation) to saturation values ranging from 0.0 (no saturation) to
1.0 (full saturation). 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): def __init__(self, r, g, b):
self.rgb = (r, g, b) self.rgb = (r, g, b)
self.color = (int(r * 256), int(g * 256), int(b * 256)) 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): def __repr__(self):
return '<Yarn %r>' % (self.rgb) 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: class Loom:
@ -64,7 +82,7 @@ class PNGLoom(Loom):
row = [] row = []
for c in fr: for c in fr:
for i in range(scale): for i in range(scale):
row.extend(c.color) row.extend(c.get_color())
for i in range(scale): for i in range(scale):
imgstr.fromlist(row) imgstr.fromlist(row)
x = len(fr * scale) x = len(fr * scale)
@ -117,39 +135,25 @@ def ascii_test():
# #
# Colors according to http://www.tartanregister.gov.uk/guidance.aspx # Colors according to http://www.tartanregister.gov.uk/guidance.aspx
# #
colors = [('A', '\x00\x44\x99'), # Azure (light blue) colors = {'R': Yarn(0.50, 0.00, 0.00), # Red
('B', '\x00\x00\x44'), # Blue 'G': Yarn(0.00, 0.40, 0.00), # Green
('C', '\xdc\x14\x3c'), # Crimson 'B': Yarn(0.00, 0.00, 0.50), # Blue
('G', '\x00\x44\x00'), # Green 'C': Yarn(0.00, 0.50, 0.50), # Cyan
('K', '\x00\x00\x00'), # Black 'Y': Yarn(0.80, 0.80, 0.00), # Yellow
('Mn', '\x80\x00\x00'), # Maroon 'P': Yarn(0.60, 0.00, 0.60), # Purple
('N', '\x44\x44\x44'), # Neutral (gray) 'W': Yarn(0.90, 0.90, 0.90), # White
('P', '\x99\x00\x99'), # Purple 'K': Yarn(0.00, 0.00, 0.00), # Black
('R', '\x99\x00\x00'), # Red (scarlet) 'BK': Yarn(0.00, 0.00, 0.00), # Black
('T', '\x66\x66\x00'), # Tan (brown) 'GR': Yarn(0.50, 0.50, 0.50), # Gray
('W', '\x99\x99\x99'), # White 'DB': Yarn(0.00, 0.00, 0.30), # Dark Blue
('Y', '\x99\x99\x00'), # Yellow 'LB': Yarn(0.00, 0.40, 0.90), # Light Blue
] 'LR': Yarn(0.80, 0.00, 0.00), # Light Red
if True: 'LG': Yarn(0.00, 0.60, 0.00), # Light Green
colors = {'R': Yarn(0.50, 0.00, 0.00), # Red 'LV': Yarn(0.50, 0.25, 0.60), # Lavender
'G': Yarn(0.00, 0.30, 0.00), # Green 'BR': Yarn(0.60, 0.40, 0.20), # Brown
'B': Yarn(0.00, 0.00, 0.50), # Blue 'LGR': Yarn(0.60, 0.60, 0.60), # Light Gray
'C': Yarn(0.00, 0.25, 0.25), # Cyan 'LBR': Yarn(0.80, 0.70, 0.50), # Light Brown
'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})')
@ -177,6 +181,8 @@ def str_to_sett(s):
o = sett[:] o = sett[:]
o.reverse() o.reverse()
sett += o sett += o
if len(sett) % 4:
sett += sett
return sett return sett
def tartan(sett): def tartan(sett):

11
tartans/or.tartan Normal file
View File

@ -0,0 +1,11 @@
Name: Oregon
Sett: Y6 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

@ -6,6 +6,8 @@ Title: TARTAN Tartan
clear: both;"> clear: both;">
</div> </div>
<p><a href="IMAGE">This image</a></p>
divert(1) divert(1)
I place this image in the public domain, in the hope that it will I place this image in the public domain, in the hope that it will