From bb63935e63365d842fe530629387d1d2a4248042 Mon Sep 17 00:00:00 2001 From: Federico Angelilli Date: Wed, 20 Nov 2024 01:20:46 +0100 Subject: Refactor changes --- src/util.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/util.c') diff --git a/src/util.c b/src/util.c index 2900a2f..80bb4a7 100644 --- a/src/util.c +++ b/src/util.c @@ -49,11 +49,25 @@ char *gradient_to_string(gradient_t *gradient) return strslice(buffer, 0, start); } +void gradient_print(FILE *stream, gradient_t *gradient) +{ + for (size_t i = 0; i < gradient->length; i++) { + unsigned int r = gradient->colors[i].r * 255, + g = gradient->colors[i].g * 255, + b = gradient->colors[i].b * 255, + a = gradient->colors[i].a * 255; + + fprintf(stream, "#%02x%02x%02x%02x", r, g, b, a); + if (i != gradient->length - 1) + fputs(", ", stream); + } +} + void gradient_free(gradient_t *gradient) { free(gradient->colors); - if (gradient->cached != NULL) - cairo_pattern_destroy(gradient->cached); + if (gradient->pattern != NULL) + cairo_pattern_destroy(gradient->pattern); } const struct timespec timespec_from_ms(long ms) -- cgit v1.2.3