Skip to content

Commit

Permalink
making sure that source colors won't be converted into chroma.colors
Browse files Browse the repository at this point in the history
  • Loading branch information
gka committed Sep 5, 2013
1 parent f9df9cf commit 5d28856
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
3 changes: 2 additions & 1 deletion chroma.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion chroma.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name" : "chroma-js",
"description" : "JavaScript library for color conversions",
"version" : "0.4.13",
"version" : "0.4.14",
"author" : "Gregor Aisch",
"homepage" : "https://github.com/gka/chroma.js",
"keywords" : ["color"],
Expand Down
4 changes: 3 additions & 1 deletion src/colorscale.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ class ColorScale
if not colors?
colors = ['#ddd', '#222']
if colors? and type(colors) == 'string' and chroma.brewer?[colors]?
colors = chroma.brewer[colors].slice(0)
colors = chroma.brewer[colors]
# make a copy of the colors
colors = colors.slice(0)
# convert to chroma classes
for c in [0..colors.length-1]
col = colors[c]
Expand Down
12 changes: 12 additions & 0 deletions test/scales-test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,18 @@ vows

#assert.deepEqual res, [0.33, 0.33, 0.33, 0.33, 0.80, 100]

'source array keeps untouched':
topic: chroma.brewer.Blues.slice(0)
'colors are an array': (colors) ->
assert.equal colors.length, 9
'colors are strings': (colors) ->
assert.equal typeof colors[0], 'string'
'creating a color scale': (colors) ->
chroma.scale(colors)
assert true
'colors are still strings': (colors) ->
assert.equal typeof colors[0], 'string'

# 'fixed color scale':
# topic: ->
# cs = new chroma.ColorScale()
Expand Down

0 comments on commit 5d28856

Please sign in to comment.