Shape operations · 6 of 6
Chaining operations
Operators chain. Every operator gives a shape, so its result can be the operand of the next one, with parentheses where needed:
shape (a + b) + 2um as merged_and_grown
shape (core + 2um) - core as trench # the 2um ring around coreThe intermediate results have no names and no layer; only the statement's result is drawn. If a join is given, it applies to every + length and - length in the statement.
Operands can also be lists built in a loop. Shapes defined inside a for block are new on every pass, and append collects them:
define holes: [shape] = []
for i in 0..count {
shape circle with 500nm as hole
place hole at (i * 2um, 0)
holes.append(hole)
}Exercise
Finish the grating. Cut all the holes out of the bar and name the result grating. Then, on slab, draw a trench: the ring between the bar's outline and 2 µm outside it, as one statement. It should also work when count changes.