MCPcopy Create free account
hub / github.com/ProgerXP/Notepad2e / VerifyContrast

Function VerifyContrast

src/Helpers.c:329–340  ·  view source on GitHub ↗

============================================================================= VerifyContrast() Check if two colors can be distinguished

Source from the content-addressed store, hash-verified

327// Check if two colors can be distinguished
328//
329BOOL VerifyContrast ( COLORREF cr1, COLORREF cr2 )
330{
331 BYTE r1 = GetRValue ( cr1 );
332 BYTE g1 = GetGValue ( cr1 );
333 BYTE b1 = GetBValue ( cr1 );
334 BYTE r2 = GetRValue ( cr2 );
335 BYTE g2 = GetGValue ( cr2 );
336 BYTE b2 = GetBValue ( cr2 );
337 return (
338 ( ( abs ( ( 3 * r1 + 5 * g1 + 1 * b1 ) - ( 3 * r2 + 6 * g2 + 1 * b2 ) ) ) >= 400 ) ||
339 ( ( abs ( r1 - r2 ) + abs ( b1 - b2 ) + abs ( g1 - g2 ) ) >= 400 ) );
340}
341
342
343//=============================================================================

Callers 1

Style_SetLexerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected