buildColor method

void buildColor()

Implementation

void buildColor() {
  int indexColorFromShift = _currentShift.toInt();
  int indexColorToShift = indexColorFromShift + 1;
  if (indexColorToShift == _colors.length) {
    indexColorToShift = 0;
  }
  Color colorFromShift = _colors[indexColorFromShift];
  Color colorToShift = _colors[indexColorToShift];
  double relativeCurrentShift = _currentShift - indexColorFromShift;
  int a = (colorFromShift.alpha +
          (colorToShift.alpha - colorFromShift.alpha) * relativeCurrentShift)
      .toInt();
  int r = (colorFromShift.red +
          (colorToShift.red - colorFromShift.red) * relativeCurrentShift)
      .toInt();
  int g = (colorFromShift.green +
          (colorToShift.green - colorFromShift.green) * relativeCurrentShift)
      .toInt();
  int b = (colorFromShift.blue +
          (colorToShift.blue - colorFromShift.blue) * relativeCurrentShift)
      .toInt();
  _currentColor = Color.fromARGB(a, r, g, b);
}