laylight tour
0/31
3/6

Shape operations · 3 of 6

Overlaps

Two more operators look at where shapes overlap:

OperatorResultLong form
a & bthe region covered by both (intersection)intersection with a, b
a ^ bthe region covered by exactly one of them (xor)xor with a, b

Together with + (or |) and -, these are the four boolean operations. They follow Python's precedence for &, ^ and |: | binds loosest, then ^, then &, and all three bind looser than + and -. So a | b & c means a | (b & c). When in doubt, add parentheses.

Exercise

Two disks overlap. Keep only their overlap, a lens, and name it lens. Then, on the slab layer, draw the parts of the disks that are not shared, as one shape named rest.

loading compiler…

Edit the code, watch the layout, then press Submit to check your solution against the exercise.

Compiling…