Skip to content

Commit

Permalink
Trying to add more variety and continuing to tweak constants
Browse files Browse the repository at this point in the history
  • Loading branch information
josephwecker committed Sep 23, 2011
1 parent 9fbfa78 commit 6f9b4a5
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions lib/autocolors/colorscheme.rb
Expand Up @@ -20,10 +20,10 @@ def generate
@contrast = nrand(0.95, 0.1, 0.75, 1.1)
# OVERALL CHROMACITY: Value between 0.0 and 1.0 used to
# contract/intensify colorfulness
@chromacity = nrand(0.7, 0.1, 0.0, 1.0)
@chromacity = nrand(0.8, 0.3, 0.0, 1.0)
# OVERALL COLORFULNESS: Value between 0.3 and 1.0 determining how many
# hues overall end up in the colorscheme
@colorfulness = nrand(0.6, 0.4, 0.3, 1.0)
@colorfulness = nrand(0.8, 0.4, 0.5, 1.0)

@intensity = rand_seq(0.0, 1.0, 8, @contrast).map{|i| simplelogit(i) * 105}
@fcolor = (0..7).map {|i| i.to_f / 7.0 * 100.0 * Math.sqrt(2.0) * @chromacity }
Expand Down Expand Up @@ -60,10 +60,10 @@ def do_concrete_mapping
ddat = entry.data.dup
fg_a, fg_b, _ = @base_colors[ldat[:fg_idx]]
bg_a, bg_b, _ = @base_colors[ldat[:bg_idx]]
ldat[:fg] = lab(light_i(ldat[:fg_intensity]), light_s(ldat[:fg_saturation]), fg_a, fg_b)
ldat[:bg] = lab(light_i(ldat[:bg_intensity]), light_s(ldat[:bg_saturation]), bg_a, bg_b)
ldat[:fg] = lab(light_i(ldat[:fg_intensity]-1), light_s(ldat[:fg_saturation]+1), fg_a, fg_b)
ldat[:bg] = lab(light_i(ldat[:bg_intensity]), light_s(ldat[:bg_saturation]), bg_a, bg_b, false)
ddat[:fg] = lab( dark_i(ldat[:fg_intensity]), dark_s(ldat[:fg_saturation]), fg_a, fg_b)
ddat[:bg] = lab( dark_i(ldat[:bg_intensity]), dark_s(ldat[:bg_saturation]), bg_a, bg_b)
ddat[:bg] = lab( dark_i(ldat[:bg_intensity]), dark_s(ldat[:bg_saturation]), bg_a, bg_b, false)
@dark[name] = ddat
@light[name] = ldat
end
Expand Down Expand Up @@ -116,12 +116,13 @@ def concrete_style(entry)
end

def dark_i(idx) @intensity[idx] end
def light_i(idx) @intensity[7 - idx] end
def light_i(idx) @intensity[[[7 - idx,0].max,7].min] end
def dark_s(idx) @fcolor[idx] end
def light_s(idx) @fcolor[idx] end
def light_s(idx) @fcolor[[idx,7].min] end

def lab(intensity, chroma, a, b)
c = Color.new([intensity, a, b])
def lab(intensity, chroma, a, b, rand_adjust=false)
ivar = rand_adjust ? (@colorfulness * rand * 16) - 8 : 0
c = Color.new([[[intensity + ivar,0].max,140].min, a, b])
c.chroma = chroma
return c
end
Expand All @@ -135,9 +136,8 @@ def new_color(base_idx, diff_level, depth)
depth = depth.to_f # Usually 1, less frequently 2, 3, to 5...
count = count.to_f # How many others already based off of the same parent
direction = rand(2) == 1 ? -1.0 : 1.0
maxdiff = @colorfulness * (1.0 / @base_colors.size) / 1.5 # allocated roughly per major color group
cdiff = direction * (maxdiff / 4.0) * depth # depth "depth-groups" away from current in random direction
cdiff += direction * (maxdiff / 4.0 / 5.0) * count # adjusted some more to avoid collisions
maxdiff = @colorfulness * (1.0 / @base_colors.size) * 1.5 # allocated roughly per major color group
cdiff = direction * maxdiff / (depth+0.5) * count * 2.5 * diff_level
cdiff += current_hue
cdiff = 1.0 + cdiff if cdiff < 0.0
cdiff = cdiff - 1.0 if cdiff > 1.0
Expand Down

0 comments on commit 6f9b4a5

Please sign in to comment.