// Boustrophedon serpentine fill of a square.
// One continuous, non-crossing line: up to the top, step right,
// down to the bottom, step right, repeat until the square is full.

// --- fill ---
let side = 60       // [20:1:84] square side, mm
let gap = 1         // [0.5:0.1:3] line spacing, mm
let passes = floor(side / gap) // derived from the exposed size and spacing

stitchlen 2

// start at the bottom-left of the fill area
up setxy(- side / 2, - side / 2) down
seth 0              // face north (up)

repeat passes [
  fd side           // run to the far edge of this pass

  // the U-turn: step over by one gap, without crossing the line
  if repcount % 2 == 1 [
    rt 90  fd gap  rt 90       // turn around to the right
  ] else [
    lt 90  fd gap  lt 90       // turn around to the left
  ]
]

trim
