HexEdit/Misc.cpp
COLORREF tone_down(COLORREF col, COLORREF bg_col, double amt /* = 0.75*/)
{
	int hue, luminance, saturation;
	get_hls(col, hue, luminance, saturation);

	int bg_hue, bg_luminance, bg_saturation;
	get_hls(bg_col, bg_hue, bg_luminance, bg_saturation);

	int diff = bg_luminance - luminance;

	// If toning "up" make sure that there is some change in the colour
	if (diff == 0 && amt < 0.0)
		diff = luminance > 50 ? 1 : -1;
	luminance += int(diff*amt);
	if (luminance > 100)
		luminance = 100;
	else if (luminance < 0)
		luminance = 0;

	// Make colour the same shade as col but less "bright"
	return get_rgb(hue, luminance, saturation);
}
// Make a colour (col) closer in tone (ie brightness or luminance) to another
// colour (bg_col) but the otherwise keep the same colour (hue/saturation).
// The parameter amt determines the amount of adjustment.
//  0 = no change
//  0.5 = default means half way to background
//  1 = fully toned down (same as background colour)
//  -ve values = tone "up"
// Note. Despite the name if bg_col is brighter than col it will "tone up".

Make a colour (col) closer in tone  to another
colour (bg_col) but the otherwise keep the same colour (hue/saturation).
The parameter amt determines the amount of adjustment.
0 = no change
0.5 = default means half way to background
1 = fully toned down (same as background colour)
ve values = tone "up"
Note. Despite the name if bg_col is brighter than col it will "tone up".
Make a colour ( col ) closer in tone to another colour ( bg_col ) but the otherwise keep the same colour ( hue / saturation ) . The parameter amt determines the amount of adjustment . 0 = no change 0 . 5 = default means half way to background 1 = fully toned down ( same as background colour ) ve values = tone " up " Note . Despite the name if bg_col is brighter than col it will " tone up " .
COLORREF tone_down(COLORREF col, COLORREF bg_col, double amt )
{
	int hue, luminance, saturation;
	get_hls(col, hue, luminance, saturation);
	int bg_hue, bg_luminance, bg_saturation;
	get_hls(bg_col, bg_hue, bg_luminance, bg_saturation);
	int diff = bg_luminance - luminance;
	if (diff == 0 && amt < 0.0)
		diff = luminance > 50 ? 1 : -1;
	luminance += int(diff*amt);
	if (luminance > 100)
		luminance = 100;
	else if (luminance < 0)
		luminance = 0;
	return get_rgb(hue, luminance, saturation);
}
COLORREF tone_down ( COLORREF col , COLORREF bg_col , double amt ) { int hue , luminance , saturation ; get_hls ( col , hue , luminance , saturation ) ; int bg_hue , bg_luminance , bg_saturation ; get_hls ( bg_col , bg_hue , bg_luminance , bg_saturation ) ; int diff = bg_luminance - luminance ; if ( diff == 0 && amt < 0.0 ) diff = luminance > 50 ? 1 : -1 ; luminance += int ( diff * amt ) ; if ( luminance > 100 ) luminance = 100 ; else if ( luminance < 0 ) luminance = 0 ; return get_rgb ( hue , luminance , saturation ) ; }
Make a colour (col) closer in tone (ie brightness or luminance) to another
colour (bg_col) but the otherwise keep the same colour (hue/saturation).
Make a colour ( col ) closer in tone ( ie brightness or luminance ) to another colour ( bg_col ) but the otherwise keep the same colour ( hue / saturation ) .
/* = 0.75*/ // If toning "up" make sure that there is some change in the colour
 // Make colour the same shade as col but less "bright"
