setRgba method

  1. @override
void setRgba(
  1. int index,
  2. num r,
  3. num g,
  4. num b,
  5. num a,
)
override

Set the RGBA color of a palette entry at index. If the palette has fewer channels than are set, the unsupported channels will be ignored.

Implementation

@override
void setRgba(int index, num r, num g, num b, num a) {
  index *= numChannels;
  data[index] = r.toInt();
  if (numChannels > 1) {
    data[index + 1] = g.toInt();
    if (numChannels > 2) {
      data[index + 2] = b.toInt();
      if (numChannels > 3) {
        data[index + 3] = a.toInt();
      }
    }
  }
}