allow hex colors without leading #
This commit is contained in:
parent
e9a205e812
commit
06234ed222
3 changed files with 11 additions and 6 deletions
|
|
@ -20,10 +20,10 @@
|
||||||
Lets assume you have created a profile with the name =fps=, containing the following color declarations:
|
Lets assume you have created a profile with the name =fps=, containing the following color declarations:
|
||||||
|
|
||||||
#+begin_src toml
|
#+begin_src toml
|
||||||
w = "aqua"
|
w = "red"
|
||||||
a = "#ff0000"
|
a = "#ff0000"
|
||||||
s = "#f0f"
|
s = "#f0f"
|
||||||
d = "white"
|
d = "ff2080"
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
All you have to do to apply the profile is to execute the following command:
|
All you have to do to apply the profile is to execute the following command:
|
||||||
|
|
@ -156,8 +156,8 @@
|
||||||
|
|
||||||
A color string can be one of the following:
|
A color string can be one of the following:
|
||||||
|
|
||||||
- Hexadecimal value with leading hash (e.g. =#ff0000=)
|
- Hexadecimal value with or without leading hash (e.g. =#ff0000=)
|
||||||
- Short hexadecimal value with leading hash (e.g. =#f0f=, then interpreted as =#ff00ff=)
|
- Short hexadecimal value with or without leading hash (e.g. =f0f=, then interpreted as =#ff00ff=)
|
||||||
- HTML color name (e.g. =green=) (a full list can be found [[https://www.w3schools.com/colors/colors_names.asp][here]])
|
- HTML color name (e.g. =green=) (a full list can be found [[https://www.w3schools.com/colors/colors_names.asp][here]])
|
||||||
|
|
||||||
Not set lights are turned off.
|
Not set lights are turned off.
|
||||||
|
|
|
||||||
7
bin/rzr
7
bin/rzr
|
|
@ -39,7 +39,12 @@ def get_color_tuple(color_string):
|
||||||
try:
|
try:
|
||||||
color = Color(color_string).rgb
|
color = Color(color_string).rgb
|
||||||
except:
|
except:
|
||||||
raise Exception("'{}' is not a valid color".format(color_string))
|
|
||||||
|
# Try again with leading #
|
||||||
|
try:
|
||||||
|
color = Color("#{}".format(color_string)).rgb
|
||||||
|
except:
|
||||||
|
raise Exception("'{}' is not a valid color".format(color_string))
|
||||||
|
|
||||||
# Scale RGB tuple from [0, 1] to [0, 255]
|
# Scale RGB tuple from [0, 1] to [0, 255]
|
||||||
color_tuple = tuple(map(lambda x: int(x * 255), color))
|
color_tuple = tuple(map(lambda x: int(x * 255), color))
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ name = "Razer BlackWidow Chroma"
|
||||||
lightmap = "blackwidow_chroma_de"
|
lightmap = "blackwidow_chroma_de"
|
||||||
|
|
||||||
[keyboard.lights]
|
[keyboard.lights]
|
||||||
logo = "#dc143c"
|
logo = "dc143c"
|
||||||
w = "coral"
|
w = "coral"
|
||||||
a = "bisque"
|
a = "bisque"
|
||||||
s = "lightgreen"
|
s = "lightgreen"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue