From: David Kastrup Date: Sun, 28 Apr 2013 12:47:42 +0000 (+0200) Subject: simplify stack-stencils and rewrite stack-stencils-padding-list X-Git-Tag: release/2.17.19-1~5^2~11 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=56533b5364a0b52502387b2f899a3a58ed0eeba2;p=lilypond.git simplify stack-stencils and rewrite stack-stencils-padding-list --- diff --git a/scm/stencil.scm b/scm/stencil.scm index fe3a84e4a4..c93dbd16ad 100644 --- a/scm/stencil.scm +++ b/scm/stencil.scm @@ -42,24 +42,23 @@ (define-public (stack-stencils axis dir padding stils) "Stack stencils @var{stils} in direction @var{axis}, @var{dir}, using @var{padding}." - (cond - ((null? stils) empty-stencil) - ((null? (cdr stils)) (car stils)) - (else (ly:stencil-combine-at-edge - (car stils) axis dir (stack-stencils axis dir padding (cdr stils)) - padding)))) - -(define-public (stack-stencils-padding-list axis dir padding stils) + (reduce + (lambda (next front) + (ly:stencil-stack front axis dir next padding)) + empty-stencil + stils)) + +(define-public (stack-stencils-padding-list axis dir paddings stils) "Stack stencils @var{stils} in direction @var{axis}, @var{dir}, using -a list of @var{padding}." - (cond - ((null? stils) empty-stencil) - ((null? (cdr stils)) (car stils)) - (else (ly:stencil-combine-at-edge - (car stils) - axis dir - (stack-stencils-padding-list axis dir (cdr padding) (cdr stils)) - (car padding))))) +a list of @var{paddings}." + (if (null? stils) + empty-stencil + (fold + (lambda (next padding front) + (ly:stencil-stack front axis dir next padding)) + (car stils) + (cdr stils) + paddings))) (define-public (centered-stencil stencil) "Center stencil @var{stencil} in both the X and Y directions."