rmthemegen 0.0.20 → 0.0.21
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/lib/rmthemegen/rgb_contrast_methods.rb +16 -0
- data/lib/rmthemegen/rmthemegen_187.rb +21 -12
- data/lib/rmthemegen/version.rb +1 -1
- data/rmthemegen.gemspec +1 -1
- data/test/test_generate_themes.rb +4 -3
- metadata +3 -6
- data/test/meana +0 -1004
- data/test/meanf +0 -11337
- data/test/meanv +0 -1004
@@ -59,6 +59,7 @@ class Color::RGB
|
|
59
59
|
(self.b-rgb.b).abs)/3
|
60
60
|
end
|
61
61
|
|
62
|
+
=begin
|
62
63
|
#returns a random number distributed about a mean (in [0..1) )
|
63
64
|
def next_gaussian(mean)
|
64
65
|
begin
|
@@ -76,6 +77,21 @@ class Color::RGB
|
|
76
77
|
# puts "next_gaussian: "+ y.to_s
|
77
78
|
return y
|
78
79
|
end
|
80
|
+
=end
|
81
|
+
|
82
|
+
#returns a random number distributed about a mean (in [0..1) )
|
83
|
+
#hopefully this algorithm delivers numbers more tightly clustered about their mean
|
84
|
+
def next_gaussian(mean)
|
85
|
+
y = (-(1.0/8.0)*(Math.log(rand)))
|
86
|
+
y = rand >= 0.5 ? y : -y
|
87
|
+
# so now y should be in [-0.5 .. 0.5]
|
88
|
+
y= y + mean
|
89
|
+
y= y > 1.0 ? 1.0 : y
|
90
|
+
y= y < 0.0 ? 0.0 : y
|
91
|
+
# puts "next_gaussian: "+ y.to_s
|
92
|
+
|
93
|
+
return y
|
94
|
+
end
|
79
95
|
|
80
96
|
end
|
81
97
|
|
@@ -89,7 +89,7 @@ module RMThemeGen
|
|
89
89
|
|
90
90
|
@backgroundcolor= randcolor( :shade_of_grey=>@background_grey, :max_bright=>@background_max_brightness)# "0"
|
91
91
|
|
92
|
-
|
92
|
+
reset_colorsets
|
93
93
|
end #def initialize
|
94
94
|
|
95
95
|
|
@@ -113,11 +113,12 @@ module RMThemeGen
|
|
113
113
|
end #8times
|
114
114
|
@color_sets << @color_set
|
115
115
|
} #rand*4times
|
116
|
-
|
117
116
|
# @color_set = {:b => rand, :g=>rand, :r => rand}
|
118
117
|
# @color_sets << @color_set
|
119
118
|
# puts @color_sets.inspect
|
119
|
+
end
|
120
120
|
|
121
|
+
def clean_colorsets
|
121
122
|
# trim each color set down to at most 2 colors
|
122
123
|
if @color_sets.size > 0
|
123
124
|
ncs = []
|
@@ -130,10 +131,10 @@ module RMThemeGen
|
|
130
131
|
end
|
131
132
|
@color_sets = ncs
|
132
133
|
# puts "@color_sets "+@color_sets.to_s
|
133
|
-
end
|
134
|
+
end
|
134
135
|
end
|
135
136
|
|
136
|
-
def
|
137
|
+
def clear_colorsets
|
137
138
|
@color_sets=[]
|
138
139
|
end
|
139
140
|
|
@@ -173,12 +174,14 @@ module RMThemeGen
|
|
173
174
|
df[:bg_rgb] = Color::RGB.from_html(df[:bg_rgb]) if df[:bg_rgb]
|
174
175
|
color = brightok = contok = nil;
|
175
176
|
cr=Color::RGB.new
|
176
|
-
failsafe
|
177
|
+
#failsafe should make sure the program never hangs trying to create
|
178
|
+
# a random color.
|
179
|
+
failsafe=20000
|
177
180
|
usecolorsets = (!@color_sets.nil? && @color_sets != [])
|
178
|
-
while (!color || !brightok || !contok ) do
|
181
|
+
while (!color || !brightok || !contok && failsafe > 0) do
|
179
182
|
if df[:shade_of_grey] == true
|
180
183
|
g = b = r = rand*256
|
181
|
-
elsif usecolorsets && failsafe >
|
184
|
+
elsif usecolorsets && failsafe > 10000
|
182
185
|
cs = @color_sets.shuffle[0]
|
183
186
|
#puts "doing gaussian thing "+cs.inspect
|
184
187
|
if cs.keys.include? :r then r = cr.next_gaussian( cs[:r])*256 else r = (df[:r] || rand*256)%256 end
|
@@ -201,7 +204,7 @@ module RMThemeGen
|
|
201
204
|
|
202
205
|
#puts "brightok "+brightok.to_s
|
203
206
|
failsafe -= 1
|
204
|
-
|
207
|
+
# if failsafe == 0 then puts "failsafe reached " end;
|
205
208
|
end #while
|
206
209
|
cn = color.html
|
207
210
|
cn= cn.slice(1,cn.size)
|
@@ -342,7 +345,8 @@ module RMThemeGen
|
|
342
345
|
f.close
|
343
346
|
end
|
344
347
|
|
345
|
-
|
348
|
+
# (output directory, bg_color_style, colorsets [])
|
349
|
+
def make_theme_file(outputdir = ENV["PWD"], bg_color_style=0, colorsets=[])
|
346
350
|
#bg_color_style: 0 = blackish, 1 = whitish, 2 = any color
|
347
351
|
defaults = {}
|
348
352
|
defaults[:outputdir] = outputdir
|
@@ -350,9 +354,15 @@ module RMThemeGen
|
|
350
354
|
opts = defaults
|
351
355
|
@bg_color_style = opts[:bg_color_style]
|
352
356
|
@background_grey = (opts[:bg_color_style] < 2) #whitish or blackish bg are both "grey"
|
353
|
-
|
354
|
-
reset_colorsets
|
355
357
|
|
358
|
+
if colorsets.is_a?(Array) && colorsets.size > 0
|
359
|
+
@color_sets = colorsets
|
360
|
+
clean_colorsets
|
361
|
+
else
|
362
|
+
reset_colorsets
|
363
|
+
end
|
364
|
+
|
365
|
+
# puts "@color_sets: "+@color_sets.inspect
|
356
366
|
case opts[:bg_color_style]
|
357
367
|
when 0 #blackish background
|
358
368
|
@background_min_brightness = 0.0
|
@@ -387,7 +397,6 @@ module RMThemeGen
|
|
387
397
|
@outf.close
|
388
398
|
return File.expand_path(@outf.path)
|
389
399
|
end
|
390
|
-
|
391
400
|
|
392
401
|
end #class
|
393
402
|
end #module
|
data/lib/rmthemegen/version.rb
CHANGED
data/rmthemegen.gemspec
CHANGED
@@ -21,7 +21,7 @@ puts
|
|
21
21
|
=begin
|
22
22
|
c=Color::RGB.new(0,0,0)
|
23
23
|
1000.times do
|
24
|
-
puts c.next_gaussian(0.
|
24
|
+
puts c.next_gaussian(0.50 )
|
25
25
|
end
|
26
26
|
Kernel.exit
|
27
27
|
=end
|
@@ -29,9 +29,10 @@ Kernel.exit
|
|
29
29
|
|
30
30
|
l = RMThemeGen::ThemeGenerator.new
|
31
31
|
|
32
|
-
|
32
|
+
5.times do
|
33
33
|
# puts l.make_theme_file(:outputdir => ENV["PWD"],:bg_color_style => 0 )
|
34
|
-
puts l.make_theme_file()
|
34
|
+
# puts l.make_theme_file(ENV["PWD"],0,[{:r=>0.0,:g=>0.0},{:r=>1.0,:g=>0.0,:b=>0.0}])
|
35
|
+
puts l.make_theme_file(ENV["PWD"],0,nil)
|
35
36
|
# puts l.make_theme_file(:outputdir => ENV["PWD"],:bg_color_style => 2 )
|
36
37
|
end
|
37
38
|
puts "testing to_css"
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rmthemegen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 53
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 21
|
10
|
+
version: 0.0.21
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- David Heitzman
|
@@ -77,9 +77,6 @@ files:
|
|
77
77
|
- rmthemegen.gemspec
|
78
78
|
- test/.~lock.mean65#
|
79
79
|
- test/index.html
|
80
|
-
- test/meana
|
81
|
-
- test/meanf
|
82
|
-
- test/meanv
|
83
80
|
- test/rmthemegen_spec.rb
|
84
81
|
- test/sample_ruby_source
|
85
82
|
- test/test_generate_themes.rb
|