-
-
Notifications
You must be signed in to change notification settings - Fork 111
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
The fill rectangles call does not apply the correct x/y offsets. (uses x and y -1 instead of +1)
com.github.romankh3.image.comparison.ImageComparison.fillRectangles(Graphics2D, List, double)
To Reproduce
Set the excluded area color, set an excluded area, set draw excluded rectangles and then get a comparison image.
Screenshots
Current behavior
fill rectangle does not cover the full exclusion area

Expected Behavior
fill rectangle fully covers the exclusion area

Fix
current code:
private void fillRectangles(Graphics2D graphics, List<Rectangle> rectangles, double percentOpacity) {
graphics.setColor(new Color(graphics.getColor().getRed(),
graphics.getColor().getGreen(),
graphics.getColor().getBlue(),
(int) (percentOpacity / 100 * 255)
));
rectangles.forEach(rectangle -> graphics.fillRect(
rectangle.getMinPoint().x - 1,
rectangle.getMinPoint().y - 1,
rectangle.getWidth() - 2,
rectangle.getHeight() - 2)
);
}
fixed code:
private void fillRectangles(Graphics2D graphics, List<Rectangle> rectangles, double percentOpacity) {
graphics.setColor(new Color(graphics.getColor().getRed(),
graphics.getColor().getGreen(),
graphics.getColor().getBlue(),
(int) (percentOpacity / 100 * 255)
));
rectangles.forEach(rectangle -> graphics.fillRect(
rectangle.getMinPoint().x + 1,
rectangle.getMinPoint().y + 1,
rectangle.getWidth() - 2,
rectangle.getHeight() - 2)
);
}
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working