From 5490ccc5ebf39759dfd084bbd31f464701a3e775 Mon Sep 17 00:00:00 2001 From: Mark Oteiza Date: Sat, 16 Sep 2017 12:49:28 -0400 Subject: Add lisp variable lcms-d65-xyz This serves as the default optional argument for functions in this library. * src/lcms.c (lcms-d65-xyz): New variable. (lcms-cam02-ucs): Use it. Use better word in docstring. Fix bug color1 -> color2. * test/src/lcms-tests.el: Add some tests for lcms-cri-cam02-ucs. (lcms-colorspacious-d65): New variable. --- src/lcms.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/lcms.c b/src/lcms.c index 1f3ace3baac..cdfbc0ecf99 100644 --- a/src/lcms.c +++ b/src/lcms.c @@ -162,7 +162,7 @@ parse_xyz_list (Lisp_Object xyz_list, cmsCIEXYZ *color) DEFUN ("lcms-cam02-ucs", Flcms_cam02_ucs, Slcms_cam02_ucs, 2, 3, 0, doc: /* Compute CAM02-UCS metric distance between COLOR1 and COLOR2. -Each color is a list of XYZ coordinates, with Y scaled to unity. +Each color is a list of XYZ coordinates, with Y scaled about unity. Optional argument is the XYZ white point, which defaults to illuminant D65. */) (Lisp_Object color1, Lisp_Object color2, Lisp_Object whitepoint) { @@ -186,15 +186,11 @@ Optional argument is the XYZ white point, which defaults to illuminant D65. */) if (!(CONSP (color1) && parse_xyz_list (color1, &xyz1))) signal_error ("Invalid color", color1); if (!(CONSP (color2) && parse_xyz_list (color2, &xyz2))) - signal_error ("Invalid color", color1); + signal_error ("Invalid color", color2); if (NILP (whitepoint)) - { - xyzw.X = 95.047; - xyzw.Y = 100.0; - xyzw.Z = 108.883; - } + parse_xyz_list (Vlcms_d65_xyz, &xyzw); else if (!(CONSP (whitepoint) && parse_xyz_list (whitepoint, &xyzw))) - signal_error("Invalid white point", whitepoint); + signal_error ("Invalid white point", whitepoint); vc.whitePoint.X = xyzw.X; vc.whitePoint.Y = xyzw.Y; @@ -295,6 +291,12 @@ DEFUN ("lcms2-available-p", Flcms2_available_p, Slcms2_available_p, 0, 0, 0, void syms_of_lcms2 (void) { + DEFVAR_LISP ("lcms-d65-xyz", Vlcms_d65_xyz, + doc: /* D65 illuminant as a CIE XYZ triple. */); + Vlcms_d65_xyz = list3 (make_float (0.950455), + make_float (1.0), + make_float (1.088753)); + defsubr (&Slcms_cie_de2000); defsubr (&Slcms_cam02_ucs); defsubr (&Slcms2_available_p); -- cgit v1.2.1