Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
F
flot
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
HS-public
flot
Commits
e58c20f3
Commit
e58c20f3
authored
Apr 12, 2013
by
David Schnur
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/k-nut/flot
into code-cleanup
parents
8e12ecd7
672b9b88
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
13 deletions
+19
-13
jquery.colorhelpers.js
jquery.colorhelpers.js
+19
-13
No files found.
jquery.colorhelpers.js
View file @
e58c20f3
...
@@ -56,9 +56,9 @@
...
@@ -56,9 +56,9 @@
return
value
<
min
?
min
:
(
value
>
max
?
max
:
value
);
return
value
<
min
?
min
:
(
value
>
max
?
max
:
value
);
}
}
o
.
r
=
clamp
(
0
,
parseInt
(
o
.
r
),
255
);
o
.
r
=
clamp
(
0
,
parseInt
(
o
.
r
,
10
),
255
);
o
.
g
=
clamp
(
0
,
parseInt
(
o
.
g
),
255
);
o
.
g
=
clamp
(
0
,
parseInt
(
o
.
g
,
10
),
255
);
o
.
b
=
clamp
(
0
,
parseInt
(
o
.
b
),
255
);
o
.
b
=
clamp
(
0
,
parseInt
(
o
.
b
,
10
),
255
);
o
.
a
=
clamp
(
0
,
o
.
a
,
1
);
o
.
a
=
clamp
(
0
,
o
.
a
,
1
);
return
o
;
return
o
;
};
};
...
@@ -68,7 +68,7 @@
...
@@ -68,7 +68,7 @@
};
};
return
o
.
normalize
();
return
o
.
normalize
();
}
}
;
// extract CSS color property from element, going up in the DOM
// extract CSS color property from element, going up in the DOM
// if it's "transparent"
// if it's "transparent"
...
@@ -78,7 +78,7 @@
...
@@ -78,7 +78,7 @@
c
=
elem
.
css
(
css
).
toLowerCase
();
c
=
elem
.
css
(
css
).
toLowerCase
();
// keep going until we find an element that has color, or
// keep going until we find an element that has color, or
// we hit the body
// we hit the body
if
(
c
!=
''
&&
c
!=
'transparent'
)
if
(
c
!=
=
''
&&
c
!=
'transparent'
)
break
;
break
;
elem
=
elem
.
parent
();
elem
=
elem
.
parent
();
}
while
(
!
$
.
nodeName
(
elem
.
get
(
0
),
"body"
));
}
while
(
!
$
.
nodeName
(
elem
.
get
(
0
),
"body"
));
...
@@ -88,7 +88,7 @@
...
@@ -88,7 +88,7 @@
c
=
"transparent"
;
c
=
"transparent"
;
return
$
.
color
.
parse
(
c
);
return
$
.
color
.
parse
(
c
);
}
}
;
// parse CSS color string (like "rgb(10, 32, 43)" or "#fff"),
// parse CSS color string (like "rgb(10, 32, 43)" or "#fff"),
// returns color object, if parsing failed, you get black (0, 0,
// returns color object, if parsing failed, you get black (0, 0,
...
@@ -97,27 +97,33 @@
...
@@ -97,27 +97,33 @@
var
res
,
m
=
$
.
color
.
make
;
var
res
,
m
=
$
.
color
.
make
;
// Look for rgb(num,num,num)
// Look for rgb(num,num,num)
if
(
res
=
/rgb
\(\s
*
([
0-9
]{1,3})\s
*,
\s
*
([
0-9
]{1,3})\s
*,
\s
*
([
0-9
]{1,3})\s
*
\)
/
.
exec
(
str
))
res
=
/rgb
\(\s
*
([
0-9
]{1,3})\s
*,
\s
*
([
0-9
]{1,3})\s
*,
\s
*
([
0-9
]{1,3})\s
*
\)
/
.
exec
(
str
);
if
(
res
)
return
m
(
parseInt
(
res
[
1
],
10
),
parseInt
(
res
[
2
],
10
),
parseInt
(
res
[
3
],
10
));
return
m
(
parseInt
(
res
[
1
],
10
),
parseInt
(
res
[
2
],
10
),
parseInt
(
res
[
3
],
10
));
// Look for rgba(num,num,num,num)
// Look for rgba(num,num,num,num)
if
(
res
=
/rgba
\(\s
*
([
0-9
]{1,3})\s
*,
\s
*
([
0-9
]{1,3})\s
*,
\s
*
([
0-9
]{1,3})\s
*,
\s
*
([
0-9
]
+
(?:\.[
0-9
]
+
)?)\s
*
\)
/
.
exec
(
str
))
res
=
/rgba
\(\s
*
([
0-9
]{1,3})\s
*,
\s
*
([
0-9
]{1,3})\s
*,
\s
*
([
0-9
]{1,3})\s
*,
\s
*
([
0-9
]
+
(?:\.[
0-9
]
+
)?)\s
*
\)
/
.
exec
(
str
);
if
(
res
)
return
m
(
parseInt
(
res
[
1
],
10
),
parseInt
(
res
[
2
],
10
),
parseInt
(
res
[
3
],
10
),
parseFloat
(
res
[
4
]));
return
m
(
parseInt
(
res
[
1
],
10
),
parseInt
(
res
[
2
],
10
),
parseInt
(
res
[
3
],
10
),
parseFloat
(
res
[
4
]));
// Look for rgb(num%,num%,num%)
// Look for rgb(num%,num%,num%)
if
(
res
=
/rgb
\(\s
*
([
0-9
]
+
(?:\.[
0-9
]
+
)?)\%\s
*,
\s
*
([
0-9
]
+
(?:\.[
0-9
]
+
)?)\%\s
*,
\s
*
([
0-9
]
+
(?:\.[
0-9
]
+
)?)\%\s
*
\)
/
.
exec
(
str
))
res
=
/rgb
\(\s
*
([
0-9
]
+
(?:\.[
0-9
]
+
)?)\%\s
*,
\s
*
([
0-9
]
+
(?:\.[
0-9
]
+
)?)\%\s
*,
\s
*
([
0-9
]
+
(?:\.[
0-9
]
+
)?)\%\s
*
\)
/
.
exec
(
str
);
if
(
res
)
return
m
(
parseFloat
(
res
[
1
])
*
2.55
,
parseFloat
(
res
[
2
])
*
2.55
,
parseFloat
(
res
[
3
])
*
2.55
);
return
m
(
parseFloat
(
res
[
1
])
*
2.55
,
parseFloat
(
res
[
2
])
*
2.55
,
parseFloat
(
res
[
3
])
*
2.55
);
// Look for rgba(num%,num%,num%,num)
// Look for rgba(num%,num%,num%,num)
if
(
res
=
/rgba
\(\s
*
([
0-9
]
+
(?:\.[
0-9
]
+
)?)\%\s
*,
\s
*
([
0-9
]
+
(?:\.[
0-9
]
+
)?)\%\s
*,
\s
*
([
0-9
]
+
(?:\.[
0-9
]
+
)?)\%\s
*,
\s
*
([
0-9
]
+
(?:\.[
0-9
]
+
)?)\s
*
\)
/
.
exec
(
str
))
res
=
/rgba
\(\s
*
([
0-9
]
+
(?:\.[
0-9
]
+
)?)\%\s
*,
\s
*
([
0-9
]
+
(?:\.[
0-9
]
+
)?)\%\s
*,
\s
*
([
0-9
]
+
(?:\.[
0-9
]
+
)?)\%\s
*,
\s
*
([
0-9
]
+
(?:\.[
0-9
]
+
)?)\s
*
\)
/
.
exec
(
str
);
if
(
res
)
return
m
(
parseFloat
(
res
[
1
])
*
2.55
,
parseFloat
(
res
[
2
])
*
2.55
,
parseFloat
(
res
[
3
])
*
2.55
,
parseFloat
(
res
[
4
]));
return
m
(
parseFloat
(
res
[
1
])
*
2.55
,
parseFloat
(
res
[
2
])
*
2.55
,
parseFloat
(
res
[
3
])
*
2.55
,
parseFloat
(
res
[
4
]));
// Look for #a0b1c2
// Look for #a0b1c2
if
(
res
=
/#
([
a-fA-F0-9
]{2})([
a-fA-F0-9
]{2})([
a-fA-F0-9
]{2})
/
.
exec
(
str
))
res
=
/#
([
a-fA-F0-9
]{2})([
a-fA-F0-9
]{2})([
a-fA-F0-9
]{2})
/
.
exec
(
str
);
if
(
res
)
return
m
(
parseInt
(
res
[
1
],
16
),
parseInt
(
res
[
2
],
16
),
parseInt
(
res
[
3
],
16
));
return
m
(
parseInt
(
res
[
1
],
16
),
parseInt
(
res
[
2
],
16
),
parseInt
(
res
[
3
],
16
));
// Look for #fff
// Look for #fff
if
(
res
=
/#
([
a-fA-F0-9
])([
a-fA-F0-9
])([
a-fA-F0-9
])
/
.
exec
(
str
))
res
=
/#
([
a-fA-F0-9
])([
a-fA-F0-9
])([
a-fA-F0-9
])
/
.
exec
(
str
);
if
(
res
)
return
m
(
parseInt
(
res
[
1
]
+
res
[
1
],
16
),
parseInt
(
res
[
2
]
+
res
[
2
],
16
),
parseInt
(
res
[
3
]
+
res
[
3
],
16
));
return
m
(
parseInt
(
res
[
1
]
+
res
[
1
],
16
),
parseInt
(
res
[
2
]
+
res
[
2
],
16
),
parseInt
(
res
[
3
]
+
res
[
3
],
16
));
// Otherwise, we're most likely dealing with a named color
// Otherwise, we're most likely dealing with a named color
...
@@ -129,7 +135,7 @@
...
@@ -129,7 +135,7 @@
res
=
lookupColors
[
name
]
||
[
0
,
0
,
0
];
res
=
lookupColors
[
name
]
||
[
0
,
0
,
0
];
return
m
(
res
[
0
],
res
[
1
],
res
[
2
]);
return
m
(
res
[
0
],
res
[
1
],
res
[
2
]);
}
}
}
}
;
var
lookupColors
=
{
var
lookupColors
=
{
aqua
:[
0
,
255
,
255
],
aqua
:[
0
,
255
,
255
],
...
...
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