Clipping

Clipping

inside_part / outside_part cut edges; they do not keep whole polygons. edges(a) & b is the same as inside_part(edges(a), b).

← Language overview

inside_part(a, b)

Available · yields edges

layer p = inside_part(a, b)
layer p = edges(a) & b

Cuts edges of A at B contours and keeps pieces whose midpoint lies in B (the border counts as inside). Polygons are turned into edges first.

Input Result

Notes

  • An edge completely in B: the whole edge.
  • An edge completely outside: dropped.
  • An edge through B: two (or more) pieces, only the inner segments.
  • A midpoint exactly on the B edge: inside.
  • A very short leftover < 1 dbu after rounding (a==b) is discarded.

outside_part(a, b)

Available · yields edges

layer p = outside_part(a, b)
layer p = edges(a) - b

Complement of inside_part: pieces whose midpoint does not lie in B.

Input Result

Notes

  • An edge along the B edge: the midpoint is on the boundary → counts as inside → not in outside_part.
  • That is the usual surprise versus “edge on edge is outside”.