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

Token class updates to accommodate new layout features #5104

Open
wants to merge 30 commits into
base: develop
Choose a base branch
from

Conversation

bubblobill
Copy link
Collaborator

@bubblobill bubblobill commented Dec 11, 2024

resolves #5103
Progresses #5096
Progresses #3691
Includes most of #5097

Description of the Change

New property
New property macro functions
Refactoring

Possible Drawbacks

none

Documentation Notes

n/a

Release Notes

n/a


This change is Reviewable

clean up some property names, e.g. isFlippedIso to flippedIso so that getter becomes isFlippedIso().

Unnecessary Token removed from property tokenOpacity. Now just opacity.

Reordered to keep layout props together.
Added new layout prop imageRotation

Updated tokenLayoutProp macro functions
@bubblobill bubblobill added feature Adding functionality that adds value claimed Issue is being actively worked on. refactor Refactoring the code for optimal awesomeness. labels Dec 11, 2024
@bubblobill bubblobill marked this pull request as draft December 11, 2024 07:20
@bubblobill
Copy link
Collaborator Author

Yay, it runs, and I am reminded why methods should be properly named the first time.
Now I just have to rewrite ZoneRenderer

@bubblobill bubblobill marked this pull request as ready for review December 13, 2024 15:11
@bubblobill
Copy link
Collaborator Author

In order to get tokens to paint properly I had to mess with ZoneRenderer. The renderTokens() code in ZR is a nightmare of repetitious code and lots of fragile non-optimal stuff.

Since ZR needs major splitting anyway, I created TokenRenderer. At present it only deals with painting tokens and I left all the weird stuff I don't understand properly behind.
TokenRenderer checks if there have been changes to the token that would impact the rendered image (layout props) and only creates new images when required.

No idea if it is faster, but image operations are performed in the following sequence with the intention of maintaining the best quality; Flip X/Y -> Flip Iso -> Scale[X, Y, XY, Footprint, and Zoom (all at once to prevent multiple scaling lossiness)] -> Rotate.

Image caches are cleared on change of zoom. Not sure if it is necessary but it seemed safer.

There are also problems with token bounds and locations. The whole everything works this way except for squares annoys the crap out of me as Everything I do is based on the token's actual position. Images are transformed such that the origin lies at their centre +/- any anchor. Translate the graphics object to the token position, scale and rotate as required and everything is easy.
With bounds, tokens have a bounding area defined by their footprint AND a bounding area that covers the token image. Think of a tree whose picture includes its canopy but the space occupied by the trunk is its footprint. Currently getBounds on a token returns the size of the whole image including offsets and scaling.
I seriously wanted to change this because it results in other things being drawn incorrectly using StG.

This is what happens if halos are drawn on offset images. Both tokens are StG. This is what the shark should look like.
image
But it snaps to the wrong place.
image

Since it has always been the case I didn't mess with it. But if all this gets through then I am mightily inclined to change it.

Icons embedded
@bubblobill bubblobill self-assigned this Dec 16, 2024
@bubblobill bubblobill requested a review from cwisniew December 16, 2024 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
claimed Issue is being actively worked on. feature Adding functionality that adds value refactor Refactoring the code for optimal awesomeness.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update Token class for new layout features
2 participants