autocolors 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.attic/colors.rb +308 -0
- data/.attic/colorscheme.rb +52 -0
- data/.attic/labtest.rb +39 -0
- data/.attic/sw2.erb +39 -0
- data/.attic/swatch.erb +39 -0
- data/.attic/swatch3.erb +14 -0
- data/.attic/test_swatch.rb +15 -0
- data/.attic/test_swatch2.rb +13 -0
- data/.yardopts +8 -0
- data/Gemfile +19 -0
- data/Gemfile.lock +40 -0
- data/LICENSE.txt +20 -0
- data/README.md +19 -0
- data/Rakefile +59 -0
- data/VERSION +1 -0
- data/analysis/textmate/textmate-in-the-wild.txt +586 -0
- data/analysis/vim/analyze-commonly-colored.sh +2 -0
- data/analysis/vim/analyze-mappings.rb +69 -0
- data/analysis/vim/common-mappings.list +1885 -0
- data/analysis/vim/commonly-colored.list +3160 -0
- data/analysis/vim/gather.sh +13 -0
- data/analysis/vim/statements.list +53490 -0
- data/autocolors.gemspec +101 -0
- data/format-samples/1/Sweyla866607.css +50 -0
- data/format-samples/1/Sweyla866607.tmTheme +255 -0
- data/format-samples/1/Sweyla866607.txt +40 -0
- data/format-samples/1/sweyla866607.el +27 -0
- data/format-samples/1/sweyla866607.vim +64 -0
- data/lib/VERSION +1 -0
- data/lib/autocolors/colors.rb +159 -0
- data/lib/autocolors/colorschemes.rb +121 -0
- data/lib/autocolors/mapping.udon +64 -0
- data/lib/autocolors/templates/colorscheme.vim +64 -0
- data/lib/autocolors.rb +6 -0
- data/notes +309 -0
- data/test/helper.rb +19 -0
- data/test/swatch.erb +19 -0
- data/test/test_autocolors.rb +7 -0
- metadata +190 -0
data/.attic/colors.rb
ADDED
@@ -0,0 +1,308 @@
|
|
1
|
+
|
2
|
+
CUBE256 = [
|
3
|
+
# Primary 3-bit (8 colors). Unique representation!
|
4
|
+
'#000000', '#800000', '#008000', '#808000', '#000080', '#800080', '#008080',
|
5
|
+
'#c0c0c0',
|
6
|
+
# Equivalent "bright" versions of original 8 colors.
|
7
|
+
'#808080', '#ff0000', '#00ff00', '#ffff00', '#0000ff', '#ff00ff', '#00ffff',
|
8
|
+
'#ffffff',
|
9
|
+
# Strictly ascending.
|
10
|
+
'#000000', '#00005f', '#000087', '#0000af', '#0000d7', '#0000ff',
|
11
|
+
'#005f00', '#005f5f', '#005f87', '#005faf', '#005fd7', '#005fff',
|
12
|
+
'#008700', '#00875f', '#008787', '#0087af', '#0087d7', '#0087ff',
|
13
|
+
'#00af00', '#00af5f', '#00af87', '#00afaf', '#00afd7', '#00afff',
|
14
|
+
'#00d700', '#00d75f', '#00d787', '#00d7af', '#00d7d7', '#00d7ff',
|
15
|
+
'#00ff00', '#00ff5f', '#00ff87', '#00ffaf', '#00ffd7', '#00ffff',
|
16
|
+
|
17
|
+
'#5f0000', '#5f005f', '#5f0087', '#5f00af', '#5f00d7', '#5f00ff',
|
18
|
+
'#5f5f00', '#5f5f5f', '#5f5f87', '#5f5faf', '#5f5fd7', '#5f5fff',
|
19
|
+
'#5f8700', '#5f875f', '#5f8787', '#5f87af', '#5f87d7', '#5f87ff',
|
20
|
+
'#5faf00', '#5faf5f', '#5faf87', '#5fafaf', '#5fafd7', '#5fafff',
|
21
|
+
'#5fd700', '#5fd75f', '#5fd787', '#5fd7af', '#5fd7d7', '#5fd7ff',
|
22
|
+
'#5fff00', '#5fff5f', '#5fff87', '#5fffaf', '#5fffd7', '#5fffff',
|
23
|
+
|
24
|
+
'#870000', '#87005f', '#870087', '#8700af', '#8700d7', '#8700ff',
|
25
|
+
'#875f00', '#875f5f', '#875f87', '#875faf', '#875fd7', '#875fff',
|
26
|
+
'#878700', '#87875f', '#878787', '#8787af', '#8787d7', '#8787ff',
|
27
|
+
'#87af00', '#87af5f', '#87af87', '#87afaf', '#87afd7', '#87afff',
|
28
|
+
'#87d700', '#87d75f', '#87d787', '#87d7af', '#87d7d7', '#87d7ff',
|
29
|
+
'#87ff00', '#87ff5f', '#87ff87', '#87ffaf', '#87ffd7', '#87ffff',
|
30
|
+
|
31
|
+
'#af0000', '#af005f', '#af0087', '#af00af', '#af00d7', '#af00ff',
|
32
|
+
'#af5f00', '#af5f5f', '#af5f87', '#af5faf', '#af5fd7', '#af5fff',
|
33
|
+
'#af8700', '#af875f', '#af8787', '#af87af', '#af87d7', '#af87ff',
|
34
|
+
'#afaf00', '#afaf5f', '#afaf87', '#afafaf', '#afafd7', '#afafff',
|
35
|
+
'#afd700', '#afd75f', '#afd787', '#afd7af', '#afd7d7', '#afd7ff',
|
36
|
+
'#afff00', '#afff5f', '#afff87', '#afffaf', '#afffd7', '#afffff',
|
37
|
+
|
38
|
+
'#d70000', '#d7005f', '#d70087', '#d700af', '#d700d7', '#d700ff',
|
39
|
+
'#d75f00', '#d75f5f', '#d75f87', '#d75faf', '#d75fd7', '#d75fff',
|
40
|
+
'#d78700', '#d7875f', '#d78787', '#d787af', '#d787d7', '#d787ff',
|
41
|
+
'#d7af00', '#d7af5f', '#d7af87', '#d7afaf', '#d7afd7', '#d7afff',
|
42
|
+
'#d7d700', '#d7d75f', '#d7d787', '#d7d7af', '#d7d7d7', '#d7d7ff',
|
43
|
+
'#d7ff00', '#d7ff5f', '#d7ff87', '#d7ffaf', '#d7ffd7', '#d7ffff',
|
44
|
+
|
45
|
+
'#ff0000', '#ff005f', '#ff0087', '#ff00af', '#ff00d7', '#ff00ff',
|
46
|
+
'#ff5f00', '#ff5f5f', '#ff5f87', '#ff5faf', '#ff5fd7', '#ff5fff',
|
47
|
+
'#ff8700', '#ff875f', '#ff8787', '#ff87af', '#ff87d7', '#ff87ff',
|
48
|
+
'#ffaf00', '#ffaf5f', '#ffaf87', '#ffafaf', '#ffafd7', '#ffafff',
|
49
|
+
'#ffd700', '#ffd75f', '#ffd787', '#ffd7af', '#ffd7d7', '#ffd7ff',
|
50
|
+
'#ffff00', '#ffff5f', '#ffff87', '#ffffaf', '#ffffd7', '#ffffff',
|
51
|
+
# Gray-scale range.
|
52
|
+
'#080808', '#121212', '#1c1c1c', '#262626', '#303030', '#3a3a3a', '#444444',
|
53
|
+
'#4e4e4e', '#585858', '#626262', '#6c6c6c', '#767676', '#808080', '#8a8a8a',
|
54
|
+
'#949494', '#9e9e9e', '#a8a8a8', '#b2b2b2', '#bcbcbc', '#c6c6c6', '#d0d0d0',
|
55
|
+
'#dadada', '#e4e4e4', '#eeeeee']
|
56
|
+
|
57
|
+
# 0 0000 => 0000 0000 (00)
|
58
|
+
# 0 0001 => 0101 1111 (5f)
|
59
|
+
# 0 0010 => 1000 0111 (87)
|
60
|
+
# 0 0011 => 1010 1111 (af)
|
61
|
+
# 0 0100 => 1101 0111 (d7)
|
62
|
+
# 0 0101 => 1111 1111 (ff)
|
63
|
+
|
64
|
+
# 0 0111
|
65
|
+
# 0 1000
|
66
|
+
# 0 1001
|
67
|
+
# 0 1010
|
68
|
+
# 0 1011
|
69
|
+
# 0 1100
|
70
|
+
|
71
|
+
# 0 1101
|
72
|
+
# 0 1110
|
73
|
+
# 0 1111
|
74
|
+
# 1 0000
|
75
|
+
# 1 0001
|
76
|
+
# 1 0010
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
class Color
|
81
|
+
attr_accessor :r, :g, :b
|
82
|
+
def initialize(colorval)
|
83
|
+
if colorval.is_a?(String) then init_string(colorval)
|
84
|
+
elsif colorval.is_a?(Integer) then init_integer(colorval)
|
85
|
+
elsif colorval.respond_to?(:to_s) then init_string(colorval.to_s)
|
86
|
+
elsif colorval.respond_to?(:to_i) then init_integer(colorval.to_i)
|
87
|
+
else raise ArgumentError, "Don't know how to convert #{colorval} into a color" end
|
88
|
+
end
|
89
|
+
|
90
|
+
def to_256
|
91
|
+
diffed = CUBE256.map do |c|
|
92
|
+
ncr = norm_contrast_ratio(c)
|
93
|
+
nbd = norm_brightness_diff(c)
|
94
|
+
ncd = norm_color_diff(c)
|
95
|
+
fd = ncd * (ncr + nbd) / 2.0
|
96
|
+
[c, [fd.round(4), ncr.round(4), nbd.round(4), ncd.round(4)]]
|
97
|
+
end
|
98
|
+
return diffed.sort_by{|c,d| d[0]}
|
99
|
+
end
|
100
|
+
|
101
|
+
def full_diff(c2)
|
102
|
+
(norm_contrast_ratio(c2)+norm_brightness_diff(c2)+norm_color_diff(c2))/ 3.0
|
103
|
+
end
|
104
|
+
|
105
|
+
def luminance
|
106
|
+
r2,g2,b2 = sRGB.map{|c| c <= 0.03928 ? c/12.92 : ((c+0.055)/1.055)**2.4 }
|
107
|
+
(0.2126 * r2) + (0.7152 * g2) + (0.0722 * b2)
|
108
|
+
end
|
109
|
+
|
110
|
+
def brightness
|
111
|
+
((r * 299.0) + (g * 587.0) + (b * 114.0)) / 1000.0
|
112
|
+
end
|
113
|
+
|
114
|
+
|
115
|
+
# http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
|
116
|
+
# No contrast: 1.0
|
117
|
+
# Good contrast: 5.0
|
118
|
+
# High contrast: 7.0
|
119
|
+
def contrast_ratio(c2)
|
120
|
+
c2=Color.new(c2) unless c2.is_a?(Color)
|
121
|
+
low,high = [luminance, c2.luminance].sort
|
122
|
+
(high + 0.05) / (low + 0.05)
|
123
|
+
end
|
124
|
+
alias :<=> :contrast_ratio
|
125
|
+
|
126
|
+
def norm_contrast_ratio(c2) contrast_ratio(c2) / 21.0 end
|
127
|
+
def norm_brightness_diff(c2) brightness_diff(c2) / 255.0 end
|
128
|
+
def norm_color_diff(c2) color_diff(c2) / (255.0 * 3.0) end
|
129
|
+
|
130
|
+
def brightness_diff(c2)
|
131
|
+
c2=Color.new(c2) unless c2.is_a?(Color)
|
132
|
+
low,high = [brightness, c2.brightness].sort
|
133
|
+
high - low
|
134
|
+
end
|
135
|
+
alias :/ :brightness_diff
|
136
|
+
|
137
|
+
def color_diff(c2)
|
138
|
+
c2 = Color.new(c2) unless c2.is_a?(Color)
|
139
|
+
rmin, rmax = [r,c2.r].sort
|
140
|
+
gmin, gmax = [g,c2.g].sort
|
141
|
+
bmin, bmax = [b,c2.b].sort
|
142
|
+
(rmax - rmin) + (gmax - gmin) + (bmax - bmin)
|
143
|
+
end
|
144
|
+
alias :- :color_diff
|
145
|
+
|
146
|
+
def to_s
|
147
|
+
'#' + r_str + g_str + b_str
|
148
|
+
end
|
149
|
+
|
150
|
+
def r_str; r.to_s(16).rjust(2,'0') end
|
151
|
+
def g_str; g.to_s(16).rjust(2,'0') end
|
152
|
+
def b_str; b.to_s(16).rjust(2,'0') end
|
153
|
+
|
154
|
+
protected
|
155
|
+
|
156
|
+
def init_string(s)
|
157
|
+
h = '[a-fA-F0-9]'
|
158
|
+
components = nil
|
159
|
+
if s =~ /^(#|0x)?(#{h}+)$/
|
160
|
+
val = $2; digits = val.split ''
|
161
|
+
if digits.size == 3
|
162
|
+
components = digits.map{|d|(d+d).to_i(16)}
|
163
|
+
elsif digits.size == 6
|
164
|
+
components = val.split(/(..)/).reject{|d|d==''}.map{|d| d.to_i(16)}
|
165
|
+
end
|
166
|
+
end
|
167
|
+
raise ArgumentError, "Wrong number of hex digits for color: #{s}" if components.nil?
|
168
|
+
@r, @g, @b = components
|
169
|
+
end
|
170
|
+
|
171
|
+
def init_integer(i) init_string('#'+i.to_s(16).rjust(6,'0')) end
|
172
|
+
|
173
|
+
def sRGB() [@r,@g,@b].map{|c| c.to_f / 255.0} end
|
174
|
+
end
|
175
|
+
|
176
|
+
require 'matrix'
|
177
|
+
# http://cs.haifa.ac.il/hagit/courses/ist/Lectures/Demos/ColorApplet2/t_convert.html
|
178
|
+
# http://en.wikipedia.org/wiki/Lab_color_space
|
179
|
+
module Colors
|
180
|
+
class RGB
|
181
|
+
attr_accessor :r,:g,:b
|
182
|
+
def initialize(rgb)
|
183
|
+
|
184
|
+
def to_a; [@r,@g,@b] end
|
185
|
+
def vals; to_a end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
class XYZ
|
190
|
+
attr_accessor :x,:y,:z
|
191
|
+
RGB2XYZ = Matrix[[0.412453,0.357580,0.180423],[0.212671,0.715160,0.072169],[0.019334,0.119193,0.950227]]
|
192
|
+
XYZ2RGB = Matrix[[3.240479,-1.537150,-0.498535],[-0.969256,1.875992,0.041556],[0.055648,-0.204043,1.057311]]
|
193
|
+
def self.from_xyz(xyz) XYZ.new(xyz) end
|
194
|
+
def self.from_rgb(rgb) n=normrgb(rgb); XYZ.new(RGB2XYZ*Matrix[[n[0]],[n[1]],[n[2]]]) end
|
195
|
+
def initialize(xyz) @x,@y,@z = xyz.to_a end
|
196
|
+
def to_rgb; (XYZ2RGB*Matrix[[@x],[@y],[@z]]).each.map{|v|v<0?0:(v>255?255:v)}.map{|v|v.round} end
|
197
|
+
def to_a; [@x,@y,@z] end
|
198
|
+
def vals; to_a end
|
199
|
+
def self.normrgb(rgb) rgb end
|
200
|
+
end
|
201
|
+
|
202
|
+
#class Lab
|
203
|
+
# attr_accessor :l,:a,:b
|
204
|
+
# def self.from_rgb(r,g,b) xyz = XYZ.from_rgb(r,g,b); Lab.from_xyz(xyz.x,xyz.y,xyz.z) end
|
205
|
+
# def self.from_xyz(x,y,z)
|
206
|
+
|
207
|
+
# end
|
208
|
+
#end
|
209
|
+
end
|
210
|
+
|
211
|
+
|
212
|
+
module Colors
|
213
|
+
LRGB2XYZ = Matrix[[0.4124,0.3576,0.1805],[0.2126,0.7152,0.0722],[0.0193,0.1192,0.9505]]
|
214
|
+
XYZ2LRGB = Matrix[[3.2406,-1.5372,-0.4986],[-0.9689,1.8758,0.0415],[0.0557,-0.2040,1.0570]]
|
215
|
+
class Color
|
216
|
+
attr_reader :rgb_approx
|
217
|
+
|
218
|
+
def initialize(rgb)
|
219
|
+
@r,@g,@b = rgb
|
220
|
+
@lab_dirty = false
|
221
|
+
@rgb_dirty = true
|
222
|
+
end
|
223
|
+
|
224
|
+
# Intermediate spaces
|
225
|
+
def lr; rgb_propagate if @rgb_dirty; lab_propagate if @lab_dirty; @lr end
|
226
|
+
def lg; rgb_propagate if @rgb_dirty; lab_propagate if @lab_dirty; @lg end
|
227
|
+
def lb; rgb_propagate if @rgb_dirty; lab_propagate if @lab_dirty; @lb end
|
228
|
+
def x; rgb_propagate if @rgb_dirty; lab_propagate if @lab_dirty; @x end
|
229
|
+
def y; rgb_propagate if @rgb_dirty; lab_propagate if @lab_dirty; @y end
|
230
|
+
def z; rgb_propagate if @rgb_dirty; lab_propagate if @lab_dirty; @z end
|
231
|
+
|
232
|
+
# CIELAB colorspace
|
233
|
+
def lab; rgb_propagate if @rgb_dirty; [@cl,@ca,@cb] end
|
234
|
+
def cl; rgb_propagate if @rgb_dirty; @cl end
|
235
|
+
def ca; rgb_propagate if @rgb_dirty; @ca end
|
236
|
+
def cb; rgb_propagate if @rgb_dirty; @cb end
|
237
|
+
def lab=(v) @lab_dirty=true; @cl,@ca,@cb=v end
|
238
|
+
def cl=(v) @lab_dirty=true; @cl=v end
|
239
|
+
def ca=(v) @lab_dirty=true; @ca=v end
|
240
|
+
def cb=(v) @lab_dirty=true; @cb=v end
|
241
|
+
|
242
|
+
# RGB colorspace
|
243
|
+
def rgb; lab_propagate if @lab_dirty; [@r,@g,@b] end
|
244
|
+
def r; lab_propagate if @lab_dirty; @r end
|
245
|
+
def g; lab_propagate if @lab_dirty; @g end
|
246
|
+
def b; lab_propagate if @lab_dirty; @b end
|
247
|
+
def rgb=(v) @rgb_dirty=true; @r,@g,@b=v end
|
248
|
+
def r=(v) @rgb_dirty=true; @r=v end
|
249
|
+
def g=(v) @rgb_dirty=true; @g=v end
|
250
|
+
def b=(v) @rgb_dirty=true; @b=v end
|
251
|
+
|
252
|
+
def to_s
|
253
|
+
'#' + rgb.map{|v|v.to_s(16).rjust(2,'0')}.join('')
|
254
|
+
end
|
255
|
+
|
256
|
+
def -(c)
|
257
|
+
if c.is_a?(Color)
|
258
|
+
# Euclidean distance in 3 dimensions
|
259
|
+
((cl - c.cl)**2 + (ca - c.ca)**2 + (cb - c.cb)**2)**0.5
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
protected
|
264
|
+
|
265
|
+
def rgb_propagate
|
266
|
+
@lr,@lg,@lb = [@r,@g,@b].map{|c|rgbc_to_lrgbc(c)}
|
267
|
+
@x,@y,@z = (LRGB2XYZ*Matrix[[@lr],[@lg],[@lb]]).to_a.flatten
|
268
|
+
@cl = (@y > 0.008856) ? 116.0*(@y ** (1.0/3.0)) - 16.0 : 903.3 * @y
|
269
|
+
@ca = 500.0 * (labf(@x) - labf(@y))
|
270
|
+
@cb = 200.0 * (labf(@y) - labf(@z))
|
271
|
+
@rgb_dirty = false
|
272
|
+
end
|
273
|
+
|
274
|
+
def lab_propagate
|
275
|
+
p = (@cl + 16.0) / 116.0
|
276
|
+
@x = (p + @ca / 500.0) ** 3.0
|
277
|
+
@y = p ** 3.0
|
278
|
+
@z = (p - @cb / 200.0) ** 3.0
|
279
|
+
@lr,@lg,@lb = (XYZ2LRGB*Matrix[[@x],[@y],[@z]]).to_a.flatten
|
280
|
+
@rgb_approx = false
|
281
|
+
@r,@g,@b = [@lr,@lg,@lb].map{|c|lrgbc_to_rgbc(c)}
|
282
|
+
@lab_dirty = false
|
283
|
+
end
|
284
|
+
|
285
|
+
def labf(t)
|
286
|
+
t > 0.008856 ? t**(1.0/3.0) : 7.787 * t + (16.0/116.0)
|
287
|
+
end
|
288
|
+
|
289
|
+
# http://en.wikipedia.org/wiki/SRGB_color_space
|
290
|
+
def rgbc_to_lrgbc(c)
|
291
|
+
cf = c.to_f / 255.0
|
292
|
+
if cf <= 0.04045 then cf / 12.92
|
293
|
+
else ((cf + 0.055) / 1.055) ** 2.4 end
|
294
|
+
end
|
295
|
+
|
296
|
+
def lrgbc_to_rgbc(c)
|
297
|
+
if c <= 0.0031308 then v = (12.92 * c * 255.0).round
|
298
|
+
else v = ((1.055 * (c ** (1.0/2.4)) - 0.055) * 255.0).round end
|
299
|
+
if v < 0 then @rgb_approx = true; 0
|
300
|
+
elsif v > 255 then @rgb_approx = true; 255
|
301
|
+
else v end
|
302
|
+
end
|
303
|
+
end
|
304
|
+
end
|
305
|
+
|
306
|
+
|
307
|
+
|
308
|
+
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'webster'
|
3
|
+
require 'colors'
|
4
|
+
|
5
|
+
class ColorScheme
|
6
|
+
attr_accessor :seed, :name
|
7
|
+
attr_accessor :dark_bg
|
8
|
+
def initialize(name=nil)
|
9
|
+
srand rand(0xffffffff)
|
10
|
+
name ||= Webster.new.random_word
|
11
|
+
@name = name
|
12
|
+
@seed = @name.hash
|
13
|
+
srand @seed
|
14
|
+
generate
|
15
|
+
end
|
16
|
+
|
17
|
+
def generate
|
18
|
+
@dark_bg = nrandcolor(0x090909)
|
19
|
+
end
|
20
|
+
|
21
|
+
protected
|
22
|
+
|
23
|
+
def nrandcolor(mean=nil)
|
24
|
+
mean ||= Color.new('#808080')
|
25
|
+
mean = Color.new(mean) unless mean.is_a?(Color)
|
26
|
+
r = nrandchan(mean.r)
|
27
|
+
g = nrandchan(mean.g)
|
28
|
+
b = nrandchan(mean.b)
|
29
|
+
Color.new((r << 16) + (g << 8) + b)
|
30
|
+
end
|
31
|
+
|
32
|
+
def nrandchan(mean=127) nrand(mean,nil,0,256) end
|
33
|
+
|
34
|
+
def nrand(mean, stddev=nil, floor=0, ceil=nil)
|
35
|
+
stddev ||= mean / 3.0
|
36
|
+
ceil ||= mean * 3.0
|
37
|
+
theta = 2 * Math::PI * rand
|
38
|
+
rho = Math.sqrt(-2 * Math.log(1 - rand))
|
39
|
+
scale = stddev * rho
|
40
|
+
res = (rand >= 0.5) ? Math.cos(theta) : Math.sin(theta)
|
41
|
+
res = (mean + scale * res).round
|
42
|
+
res = floor if res < floor
|
43
|
+
res = ceil if res > ceil
|
44
|
+
return res
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
schemes = (0..100).map{ColorScheme.new}
|
50
|
+
require 'erb'
|
51
|
+
template = ERB.new(IO.read('swatch.erb'))
|
52
|
+
puts template.result(binding)
|
data/.attic/labtest.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'colors'
|
2
|
+
|
3
|
+
class CSc
|
4
|
+
attr_accessor :name, :dark_bg
|
5
|
+
def initialize(c,i)
|
6
|
+
@name = 'colortest' + i.to_s
|
7
|
+
@dark_bg = c
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
c = Colors::Color.new([rand(256),rand(256),rand(256)])
|
12
|
+
schemes = [CSc.new(c.to_s,'or')] + (0..10).map{|i| c.ca += 20; CSc.new(c.to_s,i*10)}
|
13
|
+
c = Colors::Color.new([0,0,0])
|
14
|
+
c.cl = 0.0
|
15
|
+
c.ca = 0.0
|
16
|
+
c.cb = 0.0
|
17
|
+
schemes << CSc.new(c.to_s,1)
|
18
|
+
#schemes = [CSc.new(c.to_s,1)]
|
19
|
+
c.cl = 70.0
|
20
|
+
schemes << CSc.new(c.to_s,2)
|
21
|
+
c.ca = 50.0
|
22
|
+
schemes << CSc.new(c.to_s,3)
|
23
|
+
c.cb = 50.0
|
24
|
+
schemes << CSc.new(c.to_s,4)
|
25
|
+
c.ca = -50.0
|
26
|
+
schemes << CSc.new(c.to_s,5)
|
27
|
+
c.cb = -50.0
|
28
|
+
schemes << CSc.new(c.to_s,6)
|
29
|
+
|
30
|
+
require 'erb'
|
31
|
+
template = ERB.new(IO.read('swatch.erb'))
|
32
|
+
puts template.result(binding)
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
# #00 00 00 -> 0.0 0.0 0.0
|
37
|
+
# #ff 00 00 -> 53.2 73.8 65.7
|
38
|
+
# #00 ff 00 -> 87.7 -92.2 80.4
|
39
|
+
# #00 00 ff -> 32.3 74.4 -113.4
|
data/.attic/sw2.erb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
<style type="text/css">
|
2
|
+
div {
|
3
|
+
padding: 15px;
|
4
|
+
}
|
5
|
+
p {
|
6
|
+
font-family: Helvetica;
|
7
|
+
font-size: 12pt;
|
8
|
+
}
|
9
|
+
.rgb-color<%= ctx %> {
|
10
|
+
color: <%= rgb %>;
|
11
|
+
text-decoration: underline;
|
12
|
+
}
|
13
|
+
.rgb-bcolor<%= ctx %> {
|
14
|
+
background-color: <%= rgb %>;
|
15
|
+
width: 70px;
|
16
|
+
height: 70px;
|
17
|
+
}
|
18
|
+
.light { background-color: #fff; }
|
19
|
+
.dark { background-color: 0; }
|
20
|
+
<% nextcolors.each_with_index do |n,i| %>
|
21
|
+
.bcolor<%= ctx %>-<%= i %> { background-color: <%= n[0] %>; }
|
22
|
+
.color<%= ctx %>-<%= i %> { color: <%= n[0] %>; }
|
23
|
+
<% end %>
|
24
|
+
</style>
|
25
|
+
<!--<div class="rgb-color"> </div>-->
|
26
|
+
<div class="light">
|
27
|
+
<p class="rgb-color<%= ctx %>">The context of the text is this... (0123) [<%= rgb %>]</p>
|
28
|
+
<% nextcolors.each_with_index do |n,i| %>
|
29
|
+
<!--<div class="color<%= i %>"> </div>-->
|
30
|
+
<p class="color<%= ctx %>-<%= i %>">The context of the text is this... (0123) [<%= n[0] %> | <%= n[1] %>]</p>
|
31
|
+
<% end %>
|
32
|
+
</div>
|
33
|
+
<div class="dark">
|
34
|
+
<p class="rgb-color<%= ctx %>">The context of the text is this... (0123) [<%= rgb %>]</p>
|
35
|
+
<% nextcolors.each_with_index do |n,i| %>
|
36
|
+
<!--<div class="color<%= i %>"> </div>-->
|
37
|
+
<p class="color<%= ctx %>-<%= i %>">The context of the text is this... (0123) [<%= n[0] %> | <%= n[1] %>]</p>
|
38
|
+
<% end %>
|
39
|
+
</div>
|
data/.attic/swatch.erb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
<style type="text/css">
|
2
|
+
div {
|
3
|
+
padding: 30px;
|
4
|
+
}
|
5
|
+
p {
|
6
|
+
font-family: Helvetica;
|
7
|
+
font-size: 22pt;
|
8
|
+
}
|
9
|
+
.rgb-color<%= ctx %> {
|
10
|
+
color: <%= rgb %>;
|
11
|
+
text-decoration: underline;
|
12
|
+
}
|
13
|
+
.rgb-bcolor<%= ctx %> {
|
14
|
+
background-color: <%= rgb %>;
|
15
|
+
width: 70px;
|
16
|
+
height: 70px;
|
17
|
+
}
|
18
|
+
.light { background-color: #fff; }
|
19
|
+
.dark { background-color: 0; }
|
20
|
+
<% nextcolors.each_with_index do |n,i| %>
|
21
|
+
.bcolor<%= ctx %>-<%= i %> { background-color: <%= n[0] %>; }
|
22
|
+
.color<%= ctx %>-<%= i %> { color: <%= n[0] %>; }
|
23
|
+
<% end %>
|
24
|
+
</style>
|
25
|
+
<!--<div class="rgb-color"> </div>-->
|
26
|
+
<div class="light">
|
27
|
+
<p class="rgb-color<%= ctx %>">The context of the text is this... (0123) [<%= rgb %>]</p>
|
28
|
+
<% nextcolors.each_with_index do |n,i| %>
|
29
|
+
<!--<div class="color<%= i %>"> </div>-->
|
30
|
+
<p class="color<%= ctx %>-<%= i %>">The context of the text is this... (0123) [<%= n[0] %> | <%= n[1] %>]</p>
|
31
|
+
<% end %>
|
32
|
+
</div>
|
33
|
+
<div class="dark">
|
34
|
+
<p class="rgb-color<%= ctx %>">The context of the text is this... (0123) [<%= rgb %>]</p>
|
35
|
+
<% nextcolors.each_with_index do |n,i| %>
|
36
|
+
<!--<div class="color<%= i %>"> </div>-->
|
37
|
+
<p class="color<%= ctx %>-<%= i %>">The context of the text is this... (0123) [<%= n[0] %> | <%= n[1] %>]</p>
|
38
|
+
<% end %>
|
39
|
+
</div>
|
data/.attic/swatch3.erb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
<style type="text/css">
|
2
|
+
div { padding: 30px; margin: 30px;}
|
3
|
+
p { font-family: Helvetica; font-size: 22pt; }
|
4
|
+
</style>
|
5
|
+
<% schemes.each do |cscheme| %>
|
6
|
+
<style type="text/css">
|
7
|
+
.scheme-<%= cscheme.name %> {
|
8
|
+
background-color: <%= cscheme.dark_bg %>;
|
9
|
+
color: white;
|
10
|
+
}
|
11
|
+
</style>
|
12
|
+
<div class="scheme-<%= cscheme.name %>">[<%= cscheme.dark_bg %>] <%= cscheme.name %></div>
|
13
|
+
<% end %>
|
14
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'colors'
|
2
|
+
|
3
|
+
def swatch(rgb,ctx)
|
4
|
+
require 'erb'
|
5
|
+
template = ERB.new(IO.read('swatch.erb'))
|
6
|
+
nextcolors = Color.new(rgb).to_256
|
7
|
+
background = nextcolors.last[0]
|
8
|
+
nextcolors = nextcolors[0..2]
|
9
|
+
puts template.result(binding)
|
10
|
+
end
|
11
|
+
|
12
|
+
(1..30).each do |i|
|
13
|
+
r = '#' + rand(0xffffff).to_s(16).rjust(6,'0')
|
14
|
+
swatch(r,i)
|
15
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'colors'
|
2
|
+
|
3
|
+
def swatch(rgb,ctx)
|
4
|
+
require 'erb'
|
5
|
+
template = ERB.new(IO.read('sw2.erb'))
|
6
|
+
rgb = Colors::Color.new(rgb)
|
7
|
+
nextcolors = rgb.nearest_256
|
8
|
+
background = nextcolors.last[0]
|
9
|
+
nextcolors = nextcolors[0..0]
|
10
|
+
puts template.result(binding)
|
11
|
+
end
|
12
|
+
|
13
|
+
(1..200).each{|i| swatch([rand(0xff),rand(0xff),rand(0xff)],i)}
|
data/.yardopts
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
gem "webster", ">= 0"
|
7
|
+
|
8
|
+
# Add dependencies to develop your gem here.
|
9
|
+
# Include everything needed to run rake, tests, features, etc.
|
10
|
+
group :development do
|
11
|
+
gem "minitest", ">= 0"
|
12
|
+
gem "yard", "~> 0.6.0"
|
13
|
+
gem "bundler", "~> 1.0.0"
|
14
|
+
gem "jeweler", "~> 1.6.4"
|
15
|
+
gem "rcov", ">= 0"
|
16
|
+
gem "reek", "~> 1.2.8"
|
17
|
+
gem "roodi", "~> 2.1.0"
|
18
|
+
gem "bluecloth"
|
19
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
bluecloth (2.1.0)
|
5
|
+
git (1.2.5)
|
6
|
+
jeweler (1.6.4)
|
7
|
+
bundler (~> 1.0)
|
8
|
+
git (>= 1.2.5)
|
9
|
+
rake
|
10
|
+
minitest (2.5.1)
|
11
|
+
rake (0.9.2)
|
12
|
+
rcov (0.9.10)
|
13
|
+
reek (1.2.8)
|
14
|
+
ruby2ruby (~> 1.2)
|
15
|
+
ruby_parser (~> 2.0)
|
16
|
+
sexp_processor (~> 3.0)
|
17
|
+
roodi (2.1.0)
|
18
|
+
ruby_parser
|
19
|
+
ruby2ruby (1.3.0)
|
20
|
+
ruby_parser (~> 2.0)
|
21
|
+
sexp_processor (~> 3.0)
|
22
|
+
ruby_parser (2.3.0)
|
23
|
+
sexp_processor (~> 3.0)
|
24
|
+
sexp_processor (3.0.6)
|
25
|
+
webster (0.5.0)
|
26
|
+
yard (0.6.8)
|
27
|
+
|
28
|
+
PLATFORMS
|
29
|
+
ruby
|
30
|
+
|
31
|
+
DEPENDENCIES
|
32
|
+
bluecloth
|
33
|
+
bundler (~> 1.0.0)
|
34
|
+
jeweler (~> 1.6.4)
|
35
|
+
minitest
|
36
|
+
rcov
|
37
|
+
reek (~> 1.2.8)
|
38
|
+
roodi (~> 2.1.0)
|
39
|
+
webster
|
40
|
+
yard (~> 0.6.0)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Joseph Wecker
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Automatically create well-balanced colorschemes
|
2
|
+
|
3
|
+
* Palettes for ( mono / 16 / 256 / ffffff )
|
4
|
+
* Outputs for
|
5
|
+
- terminal emulators
|
6
|
+
- terminal programs (email readers etc.)
|
7
|
+
- editors
|
8
|
+
- vim
|
9
|
+
- emacs
|
10
|
+
- textmate
|
11
|
+
- syntax highlighters
|
12
|
+
- pygments
|
13
|
+
- perldoc
|
14
|
+
(many, many more to come)
|
15
|
+
|
16
|
+
* Possibly customized per language (different densities)
|
17
|
+
* Properly balanced for transitions across semantics/syntax/focuses
|
18
|
+
* Really good looking
|
19
|
+
* Random. muahaha
|