You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
foo = square 1# fc blue <> circle 1
main = defaultMain (hcat' with { catMethod =Distrib, sep =1.2 } (replicate5 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).
The text was updated successfully, but these errors were encountered:
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.)
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.
Consider the following example:
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).
The text was updated successfully, but these errors were encountered: