dispatchRect method

  1. @override
Uint8List dispatchRect(
  1. Uint8List data,
  2. int width,
  3. int height,
  4. Rect rect,
)
override

Implementation

@override
Uint8List dispatchRect(Uint8List data, int width, int height, Rect rect) {
  final newByte = Uint8List.fromList(data);
  final random = math.Random();
  final rand = random.nextDouble() / 2 + 0.4;
  for (int startH = rect.top; startH < rect.bottom; startH++) {
    for (int startW = rect.left; startW < rect.right; startW++) {
      final index = startH * width + startW;
      newByte[index] = (255 * math.pow(newByte[index] / 255, rand)).toInt();
    }
  }
  return newByte;
}