drawRect method

  1. @override
void drawRect(
  1. Rect rect,
  2. Color color, [
  3. BlendMode mode = BlendMode.srcOver
])
override

Draw a rect on this image with color, use the mode

Implementation

@override
void drawRect(Rect rect, Color color, [BlendMode mode = BlendMode.srcOver]) {
  BlendModeAction blend = BlendModeAction(mode);
  int maxX = min(_width, rect.right.round());
  int minY = max(0, rect.top.round());
  int maxY = min(_height, rect.bottom.round());
  for (int x = max(0, rect.left.round()); x < maxX; x++) {
    for (int y = minY; y < maxY; y++) {
      Color oColor = getColor(x, y);
      setColor(x, y, blend.blend(color, oColor));
    }
  }
}