]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/stencil.scm
remove spurious else
[lilypond.git] / scm / stencil.scm
index 8bbbed086f0c4f0efc588e033258da99ccda2e54..a457087b15913aaced436bf96942c702853e7bd3 100644 (file)
@@ -55,7 +55,12 @@ a list of @var{paddings}."
       empty-stencil
       (fold
        (lambda (next padding front)
-         (ly:stencil-stack front axis dir next padding))
+         (let ((offset (+ (- (interval-end (ly:stencil-extent front axis))
+                             (interval-start (ly:stencil-extent next axis)))
+                          padding)))
+           (ly:stencil-add
+             front
+             (ly:stencil-translate-axis next offset axis))))
        (car stils)
        (cdr stils)
        paddings)))
@@ -181,6 +186,12 @@ the more angular the shape of the parenthesis."
      (interval-widen xext (/ width 2))
      (interval-widen yext (/ width 2)))))
 
+(define-public (make-transparent-box-stencil xext yext)
+  "Make a transparent box."
+  (ly:make-stencil
+   (list 'transparent-stencil
+         (ly:stencil-expr (make-filled-box-stencil xext yext)))
+   xext yext))
 
 (define-public (make-filled-box-stencil xext yext)
   "Make a filled box."
@@ -236,20 +247,20 @@ be connected to the start by a line.
   (define (make-radius-list x-radius y-radius)
     "Makes a list of angle/radius pairs at intervals of PI/2 for
 the partial ellipse until 7*PI/2.  For example, in pseudo-code:
-> (make-radius-list 2 3)
-((0.0 . 2) (PI/2 . 3) (PI . -2) (3*PI/2 . -3)
- (2*PI . 2) (5*PI/2 . 3) (3*PI . -2) (7*PI/2 . -3))
+> (make-radius-list 2 3)\
+\n((0.0 . 2) (PI/2 . 3) (PI . -2) (3*PI/2 . -3)\
+\n(2*PI . 2) (5*PI/2 . 3) (3*PI . -2) (7*PI/2 . -3))
 "
-    (apply append
-           (map (lambda (adder)
-                  (map (lambda (quadrant)
-                         (cons (+ adder (car quadrant))
-                               (cdr quadrant)))
-                       `((0.0 . (,x-radius . 0.0))
-                         (,PI-OVER-TWO . (0.0 . ,y-radius))
-                         (,PI . (,(- x-radius) . 0.0))
-                         (,THREE-PI-OVER-TWO . (0.0 . ,(- y-radius))))))
-                `(0.0 ,TWO-PI))))
+    (append-map
+     (lambda (adder)
+       (map (lambda (quadrant)
+              (cons (+ adder (car quadrant))
+                    (cdr quadrant)))
+            `((0.0 . (,x-radius . 0.0))
+              (,PI-OVER-TWO . (0.0 . ,y-radius))
+              (,PI . (,(- x-radius) . 0.0))
+              (,THREE-PI-OVER-TWO . (0.0 . ,(- y-radius))))))
+     `(0.0 ,TWO-PI)))
 
   (define
     (insert-in-ordered-list ordering-function value inlist cutl? cutr?)
@@ -267,21 +278,21 @@ the same way but for the right side. For example:
       (helper ordering-function value left-list right-list cutl? cutr?)
       (if (null? right-list)
           (append
-            (if cutl? '() left-list)
-            (list value)
-            (if cutr? '() right-list))
+           (if cutl? '() left-list)
+           (list value)
+           (if cutr? '() right-list))
           (if (ordering-function value (car right-list))
               (append
-                (if cutl? '() left-list)
-                (list value)
-                (if cutr? '() right-list))
+               (if cutl? '() left-list)
+               (list value)
+               (if cutr? '() right-list))
               (helper
-                ordering-function
-                value
-                (append left-list (list (car right-list)))
-                (cdr right-list)
-                cutl?
-                cutr?))))
+               ordering-function
+               value
+               (append left-list (list (car right-list)))
+               (cdr right-list)
+               cutl?
+               cutr?))))
     (helper ordering-function value '() inlist cutl? cutr?))
 
   (define (ordering-function-1 a b) (car< a b))
@@ -298,7 +309,7 @@ then reduce using @var{min-max}:
 "
     (reduce min-max
             (if (eq? min-max min) 100000 -100000)
-            (map (lambda (x) (side x)) l)))
+            (map side l)))
 
   (let*
       (;; the outside limit of the x-radius
@@ -322,41 +333,41 @@ then reduce using @var{min-max}:
        ;; we want the end angle to always be bigger than the start angle
        ;; so we redefine it here just in case it is less
        (new-end-angle
-         (if (<= new-end-angle new-start-angle)
-             (+ TWO-PI new-end-angle)
-             new-end-angle))
+        (if (<= new-end-angle new-start-angle)
+            (+ TWO-PI new-end-angle)
+            new-end-angle))
        ;; all the points that may be extrema of the arc
        ;; this is the 90 degree points plus the beginning and end points
        ;; we use this to calculate extents
        (possible-extrema
+        (insert-in-ordered-list
+         ordering-function-2
+         (cons new-end-angle rectangular-end-radius)
          (insert-in-ordered-list
-           ordering-function-2
-           (cons new-end-angle rectangular-end-radius)
-           (insert-in-ordered-list
-             ordering-function-1
-             (cons new-start-angle rectangular-start-radius)
-             radius-list
-             #t
-             #f)
-           #f
-           #t)))
+          ordering-function-1
+          (cons new-start-angle rectangular-start-radius)
+          radius-list
+          #t
+          #f)
+         #f
+         #t)))
     (ly:make-stencil
-      (list
-        'partial-ellipse
-        x-radius
-        y-radius
-        start-angle
-        end-angle
-        thick
-        connect
-        fill)
-      ;; we know the extrema points by crawling through the
-      ;; list of possible extrema and finding the min and max
-      ;; for x and y
-      (cons (min-max-crawler min cadr possible-extrema)
-            (min-max-crawler max cadr possible-extrema))
-      (cons (min-max-crawler min cddr possible-extrema)
-            (min-max-crawler max cddr possible-extrema)))))
+     (list
+      'partial-ellipse
+      x-radius
+      y-radius
+      start-angle
+      end-angle
+      thick
+      connect
+      fill)
+     ;; we know the extrema points by crawling through the
+     ;; list of possible extrema and finding the min and max
+     ;; for x and y
+     (cons (min-max-crawler min cadr possible-extrema)
+           (min-max-crawler max cadr possible-extrema))
+     (cons (min-max-crawler min cddr possible-extrema)
+           (min-max-crawler max cddr possible-extrema)))))
 
 (define (line-part-min-max x1 x2)
   (list (min x1 x2) (max x1 x2)))
@@ -453,12 +464,12 @@ respectively."
                        x))
                     pointlist))
          ;; a path must begin with a `moveto'
-         (prepend-origin (apply list (cons 'moveto origin) path))
+         (prepend-origin (cons (cons 'moveto origin) path))
          ;; if this path is connected, add closepath to the end
          (final-path (if connect
-                         (append prepend-origin (list 'closepath))
+                         (append prepend-origin (list '(closepath)))
                          prepend-origin))
-         (command-list (fold-right append '() final-path)))
+         (command-list (concatenate final-path)))
     (ly:make-stencil
      `(path ,thickness
             `(,@',command-list)
@@ -641,12 +652,12 @@ with optional arrows of @code{max-size} on start and end controlled by
          (null (cons 0 0))
          (arrow-1
           (ly:make-stencil
-           `(polygon (quote ,(concatenate (map complex-to-offset p1s)))
+           `(polygon (quote ,(append-map complex-to-offset p1s))
                      0.0
                      #t) null null))
          (arrow-2
           (ly:make-stencil
-           `(polygon (quote ,(concatenate (map complex-to-offset p2s)))
+           `(polygon (quote ,(append-map complex-to-offset p2s))
                      0.0
                      #t) null null ) )
          (thickness (min (/ distance 12) 0.1))
@@ -929,4 +940,3 @@ grestore
 
   ;; should be superfluous, but leaking "too many open files"?
   (close-port output))
-