drawContour method
Image
drawContour(
- Contour contour,
- Color color,
- bool filled
)
Implementation
Image drawContour(Contour contour, Color color, bool filled) {
if (filled) {
int minX = contour.Points.first.x.toInt();
int maxX = contour.Points.first.x.toInt();
int minY = contour.Points.first.y.toInt();
int maxY = contour.Points.first.y.toInt();
for (final point in contour.Points) {
minX = point.x.toInt() < minX ? point.x.toInt() : minX;
maxX = point.x.toInt() > maxX ? point.x.toInt() : maxX;
minY = point.y.toInt() < minY ? point.y.toInt() : minY;
maxY = point.y.toInt() > maxY ? point.y.toInt() : maxY;
}
for (int y = minY; y <= maxY; y++) {
for (int x = minX; x <= maxX; x++) {
if (contour.isPointInsideContour(Point(x, y))) {
setPixel(x, y, color);
}
}
}
} else {
for (final point in contour.Points) {
setPixel(point.x.toInt(), point.y.toInt(), color);
}
}
return this;
}