New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add margins to the left and top edges of the atlas. #8657
Conversation
@@ -70,7 +70,8 @@ public List<Layout> createLayout(List<Rect> srcRects) { | |||
ArrayList<Rect> rects = new ArrayList<Rect>(page.outputRects.size()); | |||
for(RectNode node : page.outputRects) { | |||
Rect finalRect = new Rect(node.rect.getId(), node.rect.getIndex(), node.rect.getPage(), | |||
node.rect.getX(), node.rect.getY(), node.rect.getWidth() - settings.paddingX, node.rect.getHeight() - settings.paddingY, | |||
node.rect.getX() + settings.paddingX, node.rect.getY() + settings.paddingY, | |||
node.rect.getWidth() - settings.paddingX, node.rect.getHeight() - settings.paddingY, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In line 55-56 we add settings.paddingX()
and settings.paddingY
to each image rect to take it into account. Here we subtract it from rect size to restore size as it was.
This operation add margin between images + on the right and bottom edge of the atlas (because it affects rect size and 0;0 is in top left corner), but left and top edges of the atlas ignored.
To take it into account I reduce size of the atlas for margin (settings.paddingX
and settings.paddingY
) and here I move each rect position to add this space from left and top side.
throw new RuntimeException("Image does not fit with max page width " + settings.maxPageWidth + " and paddingX " | ||
+ settings.paddingX + ": " + rect); | ||
} | ||
if (rect.getHeight() > settings.maxPageHeight && (!settings.rotation || rect.getWidth() > settings.maxPageHeight)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Second half of condition doesn't make any sense, because it's already in !settings.rotation)
branch
@@ -119,14 +120,14 @@ private Page packPage(ArrayList<RectNode> inputRects) { | |||
BinarySearch sizeSearch = new BinarySearch(minSize, maxSize); | |||
int size = sizeSearch.reset(); | |||
while (size != -1) { | |||
Page result = packAtSize(true, size, size, inputRects); | |||
Page result = packAtSize(true, size - settings.paddingX, size - settings.paddingY, inputRects); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reduce all the places where we use size for margin
to be able to move all the rects from top left corner for margin
count of pixels
Fixed an issue where the margin specified for the atlas ignored the top and left edges of the atlas and was added only between images and on the right and the bottom edges of the atlas.
Fix #8584
PR checklist
Example of a well written PR description:
### Technical changes
Technical changes:
Technical notes: