Revision: 24259 http://sourceforge.net/p/bibdesk/svn/24259 Author: hofman Date: 2019-09-30 13:36:00 +0000 (Mon, 30 Sep 2019) Log Message: ----------- use saturation and brightness (lightness) to see if color is close to black or white
Modified Paths: -------------- trunk/bibdesk/NSColor_BDSKExtensions.m Modified: trunk/bibdesk/NSColor_BDSKExtensions.m =================================================================== --- trunk/bibdesk/NSColor_BDSKExtensions.m 2019-09-30 06:30:34 UTC (rev 24258) +++ trunk/bibdesk/NSColor_BDSKExtensions.m 2019-09-30 13:36:00 UTC (rev 24259) @@ -327,9 +327,10 @@ } - (BOOL)isBlackOrWhiteOrTransparentForMargin:(CGFloat)margin { - CGFloat r = 0.0, g = 0.0, b = 0.0, a = 0.0; - [[self colorUsingColorSpaceName:NSCalibratedRGBColorSpace] getRed:&r green:&g blue:&b alpha:&a]; - return (a < margin || (r > 1.0-margin && g > 1.0-margin && b > 1.0-margin) || (r < margin && g < margin && b < margin)); + CGFloat l = 0.0, s = 0.0, b = 0.0, a = 0.0; + [[self colorUsingColorSpaceName:NSCalibratedRGBColorSpace] getHue:NULL saturation:&s brightness:&b alpha:&a]; + l = (1.0 - 0.5 * s) * b; + return (a < margin || l < margin || l > 1.0 - margin); } - (uint32_t)fourByteHSBAValue { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. _______________________________________________ Bibdesk-commit mailing list Bibdesk-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bibdesk-commit