Added custom color for buttons

This commit is contained in:
Mawoka
2022-09-17 21:13:48 +02:00
parent 9cd0a5dab9
commit 4f2478c8e5
5 changed files with 37 additions and 7 deletions
+16
View File
@@ -0,0 +1,16 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
export const invertColor = (hexTripletColor: string): string => {
let color = hexTripletColor;
color = color.substring(1); // remove #
let color_int = parseInt(color, 16); // convert to integer
color_int = 0xffffff ^ color_int; // invert three bytes
color = color_int.toString(16); // convert to hex
color = ('000000' + color).slice(-6); // pad with leading zeros
color = '#' + color; // prepend #
return color;
};