fillCustomRect function

void fillCustomRect(
  1. Image image,
  2. int x0,
  3. int y0,
  4. int x1,
  5. int y1,
  6. int x2,
  7. int y2,
  8. int x3,
  9. int y3,
  10. int color,
)

Implementation

void fillCustomRect(
  Image image,
  int x0,
  int y0,
  int x1,
  int y1,
  int x2,
  int y2,
  int x3,
  int y3,
  int color,
) {
  final minY = min(min(y0, y1), min(y2, y3));
  final maxY = max(max(y0, y1), max(y2, y3));
  final minX = min(min(x0, x1), min(x2, x3));
  final maxX = max(max(x0, x1), max(x2, x3));

  for (int x = minX; x <= maxX; x++) {
    for (int y = minY; y <= maxY; y++) {
      if (_isPointInRectangle(x0, y0, x1, y1, x2, y2, x, y)) {
        drawPixel(image, x, y, color);
      }
    }
  }
}