X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=acre.c;h=b844d755153911710ebad19570b710a06d37a2db;hb=473e49a97c96edf99c4adaca72b017b632eae7fb;hp=bda8e81996c3e72cdfad5e634a7ddf132ee0902e;hpb=b58094819fb79d0d7e30ff57ddfdb7c3926302c5;p=acre diff --git a/acre.c b/acre.c index bda8e81..b844d75 100644 --- a/acre.c +++ b/acre.c @@ -28,6 +28,8 @@ #include #include +#include + typedef struct _acre_data_point_2d { double x; double y; @@ -569,8 +571,18 @@ _acre_color_from_hsv (acre_color_t *color, static void _choose_colors (acre_t *acre) { - double hue, saturation, value; + cmsHPROFILE lab_profile, srgb_profile; + cmsHTRANSFORM lab_to_srgb; int i; + double theta, radius, srgb[3]; + cmsCIELab lab; + + lab_profile = cmsCreateLabProfile (NULL); /* D50 */ + srgb_profile = cmsCreate_sRGBProfile (); + + lab_to_srgb = cmsCreateTransform (lab_profile, TYPE_Lab_DBL, + srgb_profile, TYPE_RGB_DBL, + INTENT_PERCEPTUAL, 0); acre->num_colors = acre->num_data; @@ -580,13 +592,23 @@ _choose_colors (acre_t *acre) acre->colors_size * sizeof (acre_color_t)); } - saturation = 1.0; - value = 0.7; + lab.L = 36; + radius = 130; for (i = 0; i < acre->num_colors; i++) { - hue = 360 * (double) i / acre->num_colors; - _acre_color_from_hsv (&acre->colors[i], - hue, saturation, value); + theta = 0.713 + 2 * M_PI * (double) i / acre->num_colors; + lab.a = radius * cos (theta); + lab.b = radius * sin (theta); + + cmsDoTransform (lab_to_srgb, &lab, srgb, 1); + + acre->colors[i].red = srgb[0]; + acre->colors[i].green = srgb[1]; + acre->colors[i].blue = srgb[2]; } + + cmsDeleteTransform (lab_to_srgb); + cmsCloseProfile (lab_profile); + cmsCloseProfile (srgb_profile); } static void