# Difference between revisions of "Z-order tricks"

In a vector image, every object (path, rectangle, piece of text, etc) has a position in the x-y plane, but it also has a position in the depth dimension. If you think the objects as paper cut-outs, any time two of them overlap, one must be on top of the other. Similarily, each object in a vector image occupy a slot in the z-order, which dictates which object appears on top of which (the difference to paper cut-outs is that they retain their z-position even when they are not overlapping in x-y space). You can always rearrange the z-order of your objects, within certain limits. For example, when you group objects, they retain their relative z-order to each other, but no object outside the group can occupy a z-slot between the ingroup objects.

You can use the z-ordering to you advantage, when you want areas of different colour to appear next to each other without a gap in between. As with paper cut-outs, the simplest way to do this is just to make one area to expand a bit under the other. This has the benefit that you can later adjust the positions of the paths without a gap appearing.

This approach is not possible in all situations, however. One common situation is where you have objects with a circular z-order: Object A covering part of object B, which covers part of object C, which in turn covers part of object A. In a vector image, the z-order is always linear, and to achieve the appearance of circular z-order, we need some trickery, the tools for wich are found in the Path menu.

In the image below we have an illustration of the problem. We want three ellipses of different colours stacked circularily as in top right, but with a linear z-order, the top left is best we can do. We can't put the red ellipse under the yellow one without putting it also below the green one, because that is on top of the yellow.

In order to achieve the desired effect, we need to cut off a piece out of the red ellipse that corresponds to the part that would be under the yellow one. To do this, you will first select the yellow ellipse, do "Edit -> Copy" and "Edit -> Paste in place." This will result in a copy of the yellow ellipse in exactly the same place. Then select both the copy and the the red one, and do "Path -> Difference", which will remove from the red ellipse the area overlapping the yellow one. In the bottom image is a copy of of the ellipses, with the red one moved outwards to show how it's shape is changed. This also demonstrates the drawback of the method: After you have matched the edges, you can't move the paths in relation to each other without breaking the alignement.