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

z-order attribute #76

Open
byorgey opened this issue Mar 19, 2013 · 2 comments
Open

z-order attribute #76

byorgey opened this issue Mar 19, 2013 · 2 comments

Comments

@byorgey
Copy link
Member

byorgey commented Mar 19, 2013

Consider the following example:

foo = square 1 # fc blue <> circle 1

main = defaultMain (hcat' with { catMethod = Distrib, sep = 1.2 } (replicate 5 foo))

which produces

Note how some of the circles overlap the squares, as expected. Suppose, however, that we wanted all the squares to be on top of all the circles. Currently, the only way to do that would be to draw all the circles separately from all the squares --- but this requires breaking up the definition of foo, which might be undesirable.

One simple solution (though not without problems of its own) would be to add a new "z-order" attribute, and update backends to take it into account (sorting primitives by z-order prior to drawing them).

@byorgey
Copy link
Member Author

byorgey commented Nov 4, 2013

I just wanted this again today so decided to take another look at it.

I'm removing the "easy" label: this used to be easy, when backends were just taking a list of primitives as input. But now that we (will soon be) dealing with trees, it's trickier. Probably we should not leave this up to individual backends, but add some code to do appropriate "rotations" on an RTree before handing it off to backends, so that an inorder traversal will give the primitives in the correct z-order. What makes this tricky is that it may require splitting transformation and style nodes. For example, if we have a tree like

[ blue
  [ z 1 [ circle ] ]
  [ z 2 [ square ] ]
]
[ green
  [ z 1 [ circle ] ]
  [ z 2 [ square ] ]
]

we would have to change it to something like

[ z1 [ blue [ circle ], green [ square ] ] ]
[ z2 [ blue [ square ], green [ circle ] ] ]

(I am using some horrible ad-hoc, inconsistent notation for trees above, but hopefully the idea is clear --- yell if it isn't.)

@byorgey
Copy link
Member Author

byorgey commented Nov 4, 2013

Maybe the right way to attack this is to think of it in two stages: first, implement a function to "extract" the tree containing only the primitives with a certain z-value, retaining all the relevant transformation and style nodes but throwing the rest away. Then, extract a tree for each unique z-value that occurs, and concatenate them to yield the final result.

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

No branches or pull requests

1 participant