-
-
Notifications
You must be signed in to change notification settings - Fork 133
Treemap Improvements #225
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
Treemap Improvements #225
Conversation
Update the squarification algorithm, fix the associated aspect ratio comparison, and fix the shading.
Update member declarations for squarification changes.
Tweak so that the scaling with minTileSize>0 generally leaves visible blank tiles.
First ImpressionsI like it; the treemap tiles are much more square than before. But there is a caveat: The shading is too pronounced in some cases, up to a point where the largest tiles all drown out in a dark mush; see screenshots below. Comparison Old and New/usr on my OpenSUSE Leap 15.5My Home DirectoryNotice how you can see the treemap tile boundaries in the top left corner; which is important to compare them against each other. Notice how the boundaries between the tiles became invisible in the top left corner with all that dark shading. With a click into that area, the boundary of that one tile becomes visible. |
If I understood you correctly, the new algorithm adds more ridges; one for each subdivision. Correct? If that is indeed the case, the "height" of the ridge (i.e. the light falloff) could probably be tweaked to make each ridge less pronounced so there is less contrast for each one. Could you try that? Maybe also changing the direction where the light comes from might help; top left instead of (how it looks to me) bottom right. That might put more light on the important tiles, the largest ones which are on the top left. |
There aren't any more ridges than before, but the row ridges are much smaller and it produces more contrast and hence darker darks. I agree the general appearance is darker, possibly too dark. That can be tweaked with one of three settings:
The original papers fixes ambient light at 40, and considers the other two to be configurable to taste, although it suggest a cushion height of 0.5 and height factor of between 0.5 and 1.0. The examples they show are of white cushions (I think, the paper is in black and white), so not quite as dark as using colours. |
About the "extra" row cushion. It doesn't really exist! Squarified tile cushions are deformed in both the x and y directions. In a single row, the coefficients along the short axis are identical for every tile in the row, so they can all be created at once and then that cushion surface (its coefficients and height) inherited down to the individual tiles. The row cushion is then forgotten and it isn't rendered separately. Or you can think of it as a row cushion with bumps along it if you like, but the row cushion isn't there in the final treemap. The height scale factor is only ever applied at the creation of new tiles inside a parent directory. This should probably be done in the constructor and the ability to change the height manually could be removed, but that would make it tricky to factor down the height for the dummy row cushion, because it needs its height reduced by the scale factor to match the child tiles that haven't yet been created. Anyway, I think the calculation is correct in this code, although like a lot of things it could be tidied up and speeded up. |
I just merged this into a new feature branch better-treemap for parameter tweaking before merging that branch into master. Thank you for your contributions! |
I finally found time to tune those treemap shading parameters a bit. This is the preliminary outcome: That old factor of a constant I think we can live with that result. I'll still play around a bit with it, and then I will probably merge the branch to master. |
That's pretty much what the height scale factor does, although it doesn't stop at a depth of five tiles. The 4.0 is a holdover from the illumination calculations. Really you're working with a height of 4.0 times the nominal height. The equivalent figures for the official algorithm with a height of 0.6 (4*height=2.4) and a scale factor of 0.8 are: I experimented quickly with capping the height scale factor at a height of 1.0 (starting from 4*0.6) . Less effect than I expected. Very slightly darker than the equivalent uncapped configuration. In theory, it should give very slightly darker shadows on the leaf-level tiles, but not on the larger top-level tiles. |
See also the summary in #236. |
Changes for issues #223 and #224.
createSquarifiedChildren() is modified to support full squarification, laying out each row along the shorter dimension of the remaining rectangle instead of the longer one. squarify() is largely rewritten to compile a row of tiles in the appropriate direction, choosing the row that makes the first and last tiles as close as possible to square. layoutRow() is modified to lay out and scale along the shorter side of the remaining rectangle. Rounding is controlled better to reduce tearing between tiles and ensure filling of each row. With minTileSize=0, children are scaled to exactly fit the parent tile, ignoring the allocated size of the parent, just for neatness (symlinks are still shown, or not, with zero size).
The first call to addRidge() in layoutRow() is changed to be made against a new rectangle encompassing just that row instead of the whole remaining space. This avoids the highlights being excessively pulled towards the bottom or right of the parent; they are now pulled modestly towards the centre of each row and somewhat towards the centre of their parents.
renderCushion() is modified to more closely match the algorithm in the published paper. The initial color values are scaled to avoid ambient light overflow instead of being reduced by an absolute value (ie. dark colours are darkened less). The signs of the X and Y coefficients are changed (I'm fairly sure this is how they are in the paper, but struggle to see much difference in the final cushions). Some values are pre-calculated for speed (Ia, Is, and the adjusted lightX, lightY, and lightZ could all be calculated once and stored on the parent view, but that's for another day).