+(define-public (oval-stencil stencil thickness x-padding y-padding)
+ "Add an oval around @code{stencil}, padded by the padding pair,
+ producing a new stencil."
+ (let* ((x-ext (ly:stencil-extent stencil X))
+ (y-ext (ly:stencil-extent stencil Y))
+ (x-length (+ (interval-length x-ext) x-padding thickness))
+ (y-length (+ (interval-length y-ext) y-padding thickness))
+ (x-radius (* 0.707 x-length) )
+ (y-radius (* 0.707 y-length) )
+ (oval (make-oval-stencil x-radius y-radius thickness #f)))
+
+ (ly:stencil-add
+ stencil
+ (ly:stencil-translate oval
+ (cons
+ (interval-center x-ext)
+ (interval-center y-ext))))))
+
+(define-public (ellipse-stencil stencil thickness x-padding y-padding)
+ "Add an ellipse around STENCIL, padded by the padding pair,
+ producing a new stencil."
+ (let* ((x-ext (ly:stencil-extent stencil X))
+ (y-ext (ly:stencil-extent stencil Y))
+ (x-length (+ (interval-length x-ext) x-padding thickness))
+ (y-length (+ (interval-length y-ext) y-padding thickness))
+ ;(aspect-ratio (/ x-length y-length))
+ (x-radius (* 0.707 x-length) )
+ (y-radius (* 0.707 y-length) )
+ ;(diameter (max (- (cdr x-ext) (car x-ext))
+ ; (- (cdr y-ext) (car y-ext))))
+ ;(radius (+ (/ diameter 2) padding thickness))
+ (ellipse (make-ellipse-stencil x-radius y-radius thickness #f)))
+
+ (ly:stencil-add
+ stencil
+ (ly:stencil-translate ellipse
+ (cons
+ (interval-center x-ext)
+ (interval-center y-ext))))))
+
+(define-public (rounded-box-stencil stencil thickness padding blot)
+ "Add a rounded box around STENCIL, producing a new stencil."
+
+ (let* ((xext (interval-widen (ly:stencil-extent stencil 0) padding))
+ (yext (interval-widen (ly:stencil-extent stencil 1) padding))
+ (min-ext (min (-(cdr xext) (car xext)) (-(cdr yext) (car yext))))
+ (ideal-blot (min blot (/ min-ext 2)))
+ (ideal-thickness (min thickness (/ min-ext 2)))
+ (outer (ly:round-filled-box
+ (interval-widen xext ideal-thickness)
+ (interval-widen yext ideal-thickness)
+ ideal-blot))
+ (inner (ly:make-stencil (list 'color (x11-color 'white)
+ (ly:stencil-expr (ly:round-filled-box
+ xext yext (- ideal-blot ideal-thickness)))))))
+ (set! stencil (ly:stencil-add outer inner))
+ stencil))
+