(define (extend-bounding-box r1 r2) (let ((x (min (rect-x r1) (rect-x r2))) (y (min (rect-y r1) (rect-y r2))) (w (max (rect-w r1) (rect-w r2))) (h (max (rect-w r1) (rect-w r2)))) (rect x y w h))) (define (enclosing-rect rects) (when (null? rects) (abort (usage-error "RECTS must be a list of at least one rect" 'enclosing-rect))) (fold extend-bounding-box (car rects) (cdr rects)))