setPixelRgb method

  1. @override
void setPixelRgb(
  1. int x,
  2. int y,
  3. num r,
  4. num g,
  5. num b,
)
override

Set the color of the Pixel at the given coordinates to the given color values r, g, b.

Implementation

@override
void setPixelRgb(int x, int y, num r, num g, num b) {
  final index = y * width * numChannels + (x * numChannels);
  data[index] = r.toDouble();
  if (numChannels > 1) {
    data[index + 1] = g.toDouble();
    if (numChannels > 2) {
      data[index + 2] = b.toDouble();
    }
  }
}