Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
MUR Drupal
d3-library
Commits
d3bbf394
Commit
d3bbf394
authored
Mar 23, 2014
by
Mike Bostock
Browse files
Save a few bytes.
parent
abbe1c75
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
33 deletions
+27
-33
d3.js
d3.js
+14
-17
d3.min.js
d3.min.js
+1
-1
src/color/rgb.js
src/color/rgb.js
+12
-15
No files found.
d3.js
View file @
d3bbf394
...
@@ -1620,7 +1620,7 @@
...
@@ -1620,7 +1620,7 @@
return
v
<
16
?
"
0
"
+
Math
.
max
(
0
,
v
).
toString
(
16
)
:
Math
.
min
(
255
,
v
).
toString
(
16
);
return
v
<
16
?
"
0
"
+
Math
.
max
(
0
,
v
).
toString
(
16
)
:
Math
.
min
(
255
,
v
).
toString
(
16
);
}
}
function
d3_rgb_parse
(
format
,
rgb
,
hsl
)
{
function
d3_rgb_parse
(
format
,
rgb
,
hsl
)
{
var
r
=
0
,
g
=
0
,
b
=
0
,
value
,
m1
,
m2
,
name
;
var
r
=
0
,
g
=
0
,
b
=
0
,
m1
,
m2
,
color
;
m1
=
/
([
a-z
]
+
)\((
.*
)\)
/i
.
exec
(
format
);
m1
=
/
([
a-z
]
+
)\((
.*
)\)
/i
.
exec
(
format
);
if
(
m1
)
{
if
(
m1
)
{
m2
=
m1
[
2
].
split
(
"
,
"
);
m2
=
m1
[
2
].
split
(
"
,
"
);
...
@@ -1636,22 +1636,19 @@
...
@@ -1636,22 +1636,19 @@
}
}
}
}
}
}
if
(
name
=
d3_rgb_names
.
get
(
format
))
return
rgb
(
name
.
r
,
name
.
g
,
name
.
b
);
if
(
color
=
d3_rgb_names
.
get
(
format
))
return
rgb
(
color
.
r
,
color
.
g
,
color
.
b
);
if
(
format
!=
null
&&
format
.
charAt
(
0
)
===
"
#
"
)
{
if
(
format
!=
null
&&
format
.
charAt
(
0
)
===
"
#
"
&&
!
isNaN
(
color
=
parseInt
(
format
.
substring
(
1
),
16
)))
{
value
=
parseInt
(
format
.
substring
(
1
),
16
);
if
(
format
.
length
===
4
)
{
if
(
!
isNaN
(
value
))
{
r
=
(
color
&
3840
)
>>
4
;
if
(
format
.
length
===
4
)
{
r
=
r
>>
4
|
r
;
r
=
(
value
&
3840
)
>>
4
;
g
=
color
&
240
;
r
=
r
>>
4
|
r
;
g
=
g
>>
4
|
g
;
g
=
value
&
240
;
b
=
color
&
15
;
g
=
g
>>
4
|
g
;
b
=
b
<<
4
|
b
;
b
=
value
&
15
;
}
else
if
(
format
.
length
===
7
)
{
b
=
b
<<
4
|
b
;
r
=
(
color
&
16711680
)
>>
16
;
}
else
if
(
format
.
length
===
7
)
{
g
=
(
color
&
65280
)
>>
8
;
r
=
(
value
&
16711680
)
>>
16
;
b
=
color
&
255
;
g
=
(
value
&
65280
)
>>
8
;
b
=
value
&
255
;
}
}
}
}
}
return
rgb
(
r
,
g
,
b
);
return
rgb
(
r
,
g
,
b
);
...
...
d3.min.js
View file @
d3bbf394
This diff is collapsed.
Click to expand it.
src/color/rgb.js
View file @
d3bbf394
...
@@ -67,10 +67,9 @@ function d3_rgb_parse(format, rgb, hsl) {
...
@@ -67,10 +67,9 @@ function d3_rgb_parse(format, rgb, hsl) {
var
r
=
0
,
// red channel; int in [0, 255]
var
r
=
0
,
// red channel; int in [0, 255]
g
=
0
,
// green channel; int in [0, 255]
g
=
0
,
// green channel; int in [0, 255]
b
=
0
,
// blue channel; int in [0, 255]
b
=
0
,
// blue channel; int in [0, 255]
value
,
m1
,
// CSS color specification match
m1
,
// CSS color specification match
m2
,
// CSS color specification type (e.g., rgb)
m2
,
// CSS color specification type (e.g., rgb)
name
;
color
;
/* Handle hsl, rgb. */
/* Handle hsl, rgb. */
m1
=
/
([
a-z
]
+
)\((
.*
)\)
/i
.
exec
(
format
);
m1
=
/
([
a-z
]
+
)\((
.*
)\)
/i
.
exec
(
format
);
...
@@ -95,23 +94,21 @@ function d3_rgb_parse(format, rgb, hsl) {
...
@@ -95,23 +94,21 @@ function d3_rgb_parse(format, rgb, hsl) {
}
}
/* Named colors. */
/* Named colors. */
if
(
name
=
d3_rgb_names
.
get
(
format
))
return
rgb
(
name
.
r
,
name
.
g
,
name
.
b
);
if
(
color
=
d3_rgb_names
.
get
(
format
))
return
rgb
(
color
.
r
,
color
.
g
,
color
.
b
);
/* Hexadecimal colors: #rgb and #rrggbb. */
/* Hexadecimal colors: #rgb and #rrggbb. */
if
(
format
!=
null
&&
format
.
charAt
(
0
)
===
"
#
"
)
{
if
(
format
!=
null
&&
format
.
charAt
(
0
)
===
"
#
"
&&
!
isNaN
(
color
=
parseInt
(
format
.
substring
(
1
),
16
)))
{
value
=
parseInt
(
format
.
substring
(
1
),
16
);
if
(
format
.
length
===
4
)
{
if
(
!
isNaN
(
value
))
{
r
=
(
color
&
0xf00
)
>>
4
;
r
=
(
r
>>
4
)
|
r
;
if
(
format
.
length
===
4
)
{
g
=
(
color
&
0xf0
);
g
=
(
g
>>
4
)
|
g
;
r
=
(
value
&
0xf00
)
>>
4
;
r
=
(
r
>>
4
)
|
r
;
b
=
(
color
&
0xf
);
b
=
(
b
<<
4
)
|
b
;
g
=
(
value
&
0xf0
);
g
=
(
g
>>
4
)
|
g
;
}
else
if
(
format
.
length
===
7
)
{
b
=
(
value
&
0xf
);
b
=
(
b
<<
4
)
|
b
;
r
=
(
color
&
0xff0000
)
>>
16
;
}
else
if
(
format
.
length
===
7
)
{
g
=
(
color
&
0xff00
)
>>
8
;
r
=
(
value
&
0xff0000
)
>>
16
;
b
=
(
color
&
0xff
);
g
=
(
value
&
0xff00
)
>>
8
;
b
=
(
value
&
0xff
);
}
}
}
}
}
return
rgb
(
r
,
g
,
b
);
return
rgb
(
r
,
g
,
b
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment