Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
scc-net
netvs
netvs-core
Commits
978fcfb6
Commit
978fcfb6
authored
Feb 19, 2020
by
gj4210
👁
Browse files
ADD: colorutils to handle hashed colors consistently across frontend
parent
7ca4635d
Changes
1
Hide whitespace changes
Inline
Side-by-side
frontend/src/util/colorutil.js
0 → 100644
View file @
978fcfb6
// https://gist.github.com/0x263b/2bdd90886c2036a1ad5bcf06d6e6fb37
// (modified)
String
.
prototype
.
toHSL
=
function
(
opts
)
{
let
h
,
s
,
l
;
opts
=
opts
||
{};
opts
.
hue
=
opts
.
hue
||
[
0
,
360
];
opts
.
sat
=
opts
.
sat
||
[
75
,
100
];
opts
.
lit
=
opts
.
lit
||
[
40
,
60
];
let
range
=
function
(
hash
,
min
,
max
)
{
let
diff
=
max
-
min
;
let
x
=
((
hash
%
diff
)
+
diff
)
%
diff
;
return
x
+
min
;
}
let
hash
=
0
;
if
(
this
.
length
===
0
)
return
hash
;
for
(
let
i
=
0
;
i
<
this
.
length
;
i
++
)
{
hash
=
this
.
charCodeAt
(
i
)
+
((
hash
<<
5
)
-
hash
);
hash
=
hash
&
hash
;
}
h
=
range
(
hash
,
opts
.
hue
[
0
],
opts
.
hue
[
1
]);
s
=
range
(
hash
,
opts
.
sat
[
0
],
opts
.
sat
[
1
]);
l
=
range
(
hash
,
opts
.
lit
[
0
],
opts
.
lit
[
1
]);
return
`hsl(
${
h
}
,
${
s
}
%,
${
l
}
%)`
;
}
\ No newline at end of file
Write
Preview
Supports
Markdown
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