[go: nahoru, domu]

Skip to content

Commit

Permalink
Merge branch 'case-insensitive-color-names' of https://github.com/wil…
Browse files Browse the repository at this point in the history
…g/d3 into 3.5.4
  • Loading branch information
mbostock committed Feb 7, 2015
2 parents 4b6bd05 + 82a0f01 commit 36fd534
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 4 deletions.
4 changes: 3 additions & 1 deletion d3.js
Original file line number Diff line number Diff line change
Expand Up @@ -1712,7 +1712,9 @@
}
}
}
if (color = d3_rgb_names.get(format)) return rgb(color.r, color.g, color.b);
if (color = d3_rgb_names.get(format.toLowerCase())) {
return rgb(color.r, color.g, color.b);
}
if (format != null && format.charAt(0) === "#" && !isNaN(color = parseInt(format.slice(1), 16))) {
if (format.length === 4) {
r = (color & 3840) >> 4;
Expand Down
4 changes: 2 additions & 2 deletions d3.min.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/color/rgb.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ function d3_rgb_parse(format, rgb, hsl) {
}

/* Named colors. */
if (color = d3_rgb_names.get(format)) return rgb(color.r, color.g, color.b);
if (color = d3_rgb_names.get(format.toLowerCase())) {
return rgb(color.r, color.g, color.b);
}

/* Hexadecimal colors: #rgb and #rrggbb. */
if (format != null && format.charAt(0) === "#" && !isNaN(color = parseInt(format.slice(1), 16))) {
Expand Down
3 changes: 3 additions & 0 deletions test/color/hcl-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ suite.addBatch({
"parses color names (e.g., \"moccasin\")": function(d3) {
assert.hclEqual(d3.hcl("moccasin"), 84.71288921124494, 26.472460854104156, 91.72317744746022);
},
"parses color names (e.g., \"Moccasin\")": function(d3) {
assert.hclEqual(d3.hcl("moccasin"), 84.71288921124494, 26.472460854104156, 91.72317744746022);
},
"parses and converts RGB format (e.g., \"rgb(102, 102, 0)\")": function(d3) {
assert.hclEqual(d3.hcl("rgb(102, 102, 0)"), 102.85124420310271, 49.44871600399321, 41.73251953866431);
},
Expand Down
3 changes: 3 additions & 0 deletions test/color/hsl-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ suite.addBatch({
assert.hslEqual(d3.hsl("moccasin"), 38.108108, 1, .854902);
assert.hslEqual(d3.hsl("aliceblue"), 208, 1, .970588);
assert.hslEqual(d3.hsl("yellow"), 60, 1, .5);
assert.hslEqual(d3.hsl("Moccasin"), 38.108108, 1, .854902);
assert.hslEqual(d3.hsl("Aliceblue"), 208, 1, .970588);
assert.hslEqual(d3.hsl("Yellow"), 60, 1, .5);
},
"parses and converts RGB format (e.g., \"rgb(102, 102, 0)\")": function(d3) {
assert.hslEqual(d3.hsl("rgb(102, 102, 0)"), 60, 1, .2);
Expand Down
3 changes: 3 additions & 0 deletions test/color/lab-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ suite.addBatch({
"parses color names (e.g., \"moccasin\")": function(d3) {
assert.labEqual(d3.lab("moccasin"), 91.72317744746022, 2.4393469358685027, 26.359832514614844);
},
"parses color names (e.g., \"Moccasin\")": function(d3) {
assert.labEqual(d3.lab("Moccasin"), 91.72317744746022, 2.4393469358685027, 26.359832514614844);
},
"parses and converts RGB format (e.g., \"rgb(102, 102, 0)\")": function(d3) {
assert.labEqual(d3.lab("rgb(102, 102, 0)"), 41.73251953866431, -10.998411255098816, 48.21006600604577);
},
Expand Down
3 changes: 3 additions & 0 deletions test/color/rgb-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ suite.addBatch({
assert.rgbEqual(d3.rgb("moccasin"), 255, 228, 181);
assert.rgbEqual(d3.rgb("aliceblue"), 240, 248, 255);
assert.rgbEqual(d3.rgb("yellow"), 255, 255, 0);
assert.rgbEqual(d3.rgb("Moccasin"), 255, 228, 181);
assert.rgbEqual(d3.rgb("Aliceblue"), 240, 248, 255);
assert.rgbEqual(d3.rgb("Yellow"), 255, 255, 0);
},
"parses \"rebeccapurple\"": function(d3) {
assert.rgbEqual(d3.rgb("rebeccapurple"), 102, 51, 153);
Expand Down

0 comments on commit 36fd534

Please sign in to comment.