options: support shadow-color as a commandline option

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui
2020-08-18 02:39:43 +01:00
parent e90bd92a53
commit 2b677c8fc4
3 changed files with 28 additions and 15 deletions

View File

@@ -15,6 +15,7 @@
#include <test.h>
#include "compiler.h"
#include "types.h"
#define ARR_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
@@ -165,6 +166,21 @@ static inline double attr_const normalize_d(double d) {
return normalize_d_range(d, 0.0, 1.0);
}
/**
* Convert a hex RGB string to RGB
*/
static inline struct color hex_to_rgb(const char *hex) {
struct color rgb;
// Ignore the # in front of the string
const char *sane_hex = hex + 1;
int hex_color = (int)strtol(sane_hex, NULL, 16);
rgb.red = (float)(hex_color >> 16) / 256;
rgb.green = (float)((hex_color & 0x00ff00) >> 8) / 256;
rgb.blue = (float)(hex_color & 0x0000ff) / 256;
return rgb;
}
attr_noret void
report_allocation_failure(const char *func, const char *file, unsigned int line);