How can I draw a line in cetz over any other regardless?

#set page(width: auto, height: auto, margin: 0.5cm)
#import "@preview/cetz:0.4.2"

#cetz.canvas({import cetz.draw: *
	ortho(x:120deg,y:180deg,z:10deg,{
		intersections("i", {
			line((1,1,0),(-1,-1,0),(-1,-1,3),(1,1,3),close:true)
			line((-1,1,0),(1,-1,0),(1,-1,3),(-1,1,3),close:true)
		})
		line("i.0","i.2",stroke:red+2pt)
	})
})

I want to draw the red line over the two outlined squares, but spatially the red line is behind the front of the image, so it gets drawn under.

If I fill any of the squares the line disappear from display:

The ortho function has some naive z-ordering. You can either disable that or use on-layer(...) to move the line to a higher layer number and therefore draw it on top.

4 Likes