Skip to content
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

Draw map boundary so it doesn't overlap the map #3835

Closed
wants to merge 1 commit into from
Closed

Draw map boundary so it doesn't overlap the map #3835

wants to merge 1 commit into from

Conversation

eishiya
Copy link
Contributor

@eishiya eishiya commented Oct 24, 2023

Currently, the top and left border of the map overlap tile pixels, while the right and bottom do not. This change adjusts the border to be outside the map on all four sides. This is especially helpful for pixel art maps at low zooms, where those overlapped pixels can matter quite a bit.

This change offsets the top left corner by -1,-1 with the assumption that the border is always 1px wide because I could not find any code that ever sets the pen width. If the pen width is dynamic, then this offset will need to be adjusted for the width.

I'm not 100% sure I'm using QRect.adjust() correctly (I half-expect the Qt docs to be lying about how it works), but I need an autobuild to check, hence the early PR :] Will edit after I've tested.

Edit: Ah, of course I failed to account for scaling! The (-1,-1,0,0) adjustment needs to happen to the scaled rect, not the original rect. The good news is QRect.adjust() works like I thought :D

Currently, the top and left border of the map overlap tile pixels, while the right and bottom do not. This change adjusts the border to always be outside the map.

This change offsets the top left corner by -1,-1 with the assumption that the border is always 1px wide because I could not find any code that ever sets the pen width. If the pen width is dynamic, then this offset will need to be adjusted for the width.
@eishiya eishiya marked this pull request as draft October 25, 2023 00:06
@eishiya eishiya closed this Oct 25, 2023
@eishiya eishiya deleted the patch-1 branch October 25, 2023 00:32
@eishiya
Copy link
Contributor Author

eishiya commented Oct 25, 2023

Unfortunately, due to the facts that the rectangle and its offset get scaled and we don't get to control/access the final scaled rectangle to adjust its position and size to add the necessary pixels, and that Qt provides no option to add outer strokes to rectangles instead of centre strokes, I could not make this work ):

Perhaps an option to disable the map boundary rect would be a viable alternative.

@bjorn
Copy link
Member

bjorn commented Oct 25, 2023

Unfortunately, due to the facts that the rectangle and its offset get scaled and we don't get to control/access the final scaled rectangle to adjust its position and size to add the necessary pixels, and that Qt provides no option to add outer strokes to rectangles instead of centre strokes, I could not make this work ):

Yeah, I have been bothered by the same issue, but have no solution either. I think the only option might be to disable scaling for that item, calculate its scaled size manually, and then to apply the one pixel change. It's a lot of bother for a small issue, though...

Another solution might be to render the rectangle behind rather than on top of the map, with a thicker line so it would show beyond the top-left edges. Though of course, then you can no longer see it when you have placed some objects on top.

Perhaps an option to disable the map boundary rect would be a viable alternative.

Yeah, such an option should be added regardless.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants