tone method

TColor tone(
  1. double val
)

Implementation

TColor tone(double val)
{
  if(val == 0)
  {
    if(this is TAlphaColor)
      return TAlphaColor(value, (this as TAlphaColor).alphaBlend);
    return TColor(value);
  }
  var clr = toColorRef();
  if(clr == null)
    return clDefault;

  int red = clr.red;
  int green = clr.green;
  int blue = clr.blue;
  if(val>0)
  {
    if(val>1.0)
      val = 1.0;
    red = 255 - red;
    green = 255 - green;
    blue = 255 - blue;
  }
  else
  if(val<-1.0)
    val = -1.0;

  return _same(clr.red + (red * val).round(),
               clr.green + (green * val).round(),
               clr.blue + (blue * val).round());
}