home | blog | art | now | git gpg | email | rss

morph

Generate xresources colors from an image.
git clone https://pollux.codes/git/morph.git
Log | Files | Refs | README | LICENSE
commit e5309c10078b6479f53a83f28b53339362f7c05d
parent 8f5068ee106057673a70658fdf61e93b10e00ae7
Author: Pollux <pollux@pollux.codes>
Date:   Sun, 20 Jul 2025 21:07:34 -0500

fix: Fine-tune algorithm

Signed-off-by: Pollux <pollux@pollux.codes>

Diffstat:
Mmorph.c | 13+++++++------
1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/morph.c b/morph.c @@ -316,8 +316,9 @@ match_color(col_lab_t *palette, float *palette_weights, size_t palette_size, for(int c = 0; c < palette_size; c++) { col_lab_t palette_color = palette[c]; float color_distance = - sqrtf(0.2 * (palette_color.l - target_color.l) * - (palette_color.l - target_color.l) + + sqrtf((palette_color.l - + target_color.l) * (palette_color.l - + target_color.l) + (palette_color.a - target_color.a) * (palette_color.a - target_color.a) + @@ -387,7 +388,7 @@ main(int argc, char **argv) { col_lab_t color; - TARGET_COLOR("st.color0", 0, 0, 0, 0.2); + TARGET_COLOR("st.color0", 0, 0, 0, 0.25); TARGET_COLOR("st.color1", 1, 0, 0, 0.7); TARGET_COLOR("st.color2", 0, 1, 0, 0.7); TARGET_COLOR("st.color3", 1, 1, 0, 0.7); @@ -402,9 +403,9 @@ main(int argc, char **argv) { TARGET_COLOR("st.color12", 0, 0, 1, 0.8); TARGET_COLOR("st.color13", 1, 0, 1, 0.8); TARGET_COLOR("st.color14", 0, 1, 1, 0.8); - TARGET_COLOR("st.color15", 0, 0, 0, 1.0); - TARGET_COLOR("st.surface", 0, 0, 0, 0.1); - TARGET_COLOR("st.on_surface", 0, 0, 0, 1.0); + TARGET_COLOR("st.color15", 0, 0, 0, 0.9); + TARGET_COLOR("st.surface", 0, 0, 0, 0.15); + TARGET_COLOR("st.on_surface", 0, 0, 0, 0.95); free(image_pixels); free(image_pixels_lab);