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:
|
||||
|
||||
#+begin_src toml
|
||||
w = "aqua"
|
||||
w = "red"
|
||||
a = "#ff0000"
|
||||
s = "#f0f"
|
||||
d = "white"
|
||||
d = "ff2080"
|
||||
#+end_src
|
||||
|
||||
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:
|
||||
|
||||
- Hexadecimal value with leading hash (e.g. =#ff0000=)
|
||||
- Short hexadecimal value with leading hash (e.g. =#f0f=, then interpreted as =#ff00ff=)
|
||||
- Hexadecimal value with or without leading hash (e.g. =#ff0000=)
|
||||
- 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]])
|
||||
|
||||
Not set lights are turned off.
|
||||
|
|
|
|||
7
bin/rzr
7
bin/rzr
|
|
@ -39,7 +39,12 @@ def get_color_tuple(color_string):
|
|||
try:
|
||||
color = Color(color_string).rgb
|
||||
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]
|
||||
color_tuple = tuple(map(lambda x: int(x * 255), color))
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ name = "Razer BlackWidow Chroma"
|
|||
lightmap = "blackwidow_chroma_de"
|
||||
|
||||
[keyboard.lights]
|
||||
logo = "#dc143c"
|
||||
logo = "dc143c"
|
||||
w = "coral"
|
||||
a = "bisque"
|
||||
s = "lightgreen"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue