]> git.donarmstrong.com Git - lilypond.git/commitdiff
\rounded-box corrections
authorValentin Villenave <valentin@villenave.net>
Mon, 21 Apr 2008 14:59:41 +0000 (16:59 +0200)
committerValentin Villenave <valentin@villenave.net>
Mon, 21 Apr 2008 14:59:41 +0000 (16:59 +0200)
Added an example, and corrected a bit the algorithm.

scm/define-markup-commands.scm
scm/stencil.scm

index 9ddfa4982096cf906a1c99f26c5eacb8e111251e..e5d7196cd1cbfe90cfb369b3fd57ae22e314053d 100644 (file)
@@ -206,7 +206,12 @@ circle of diameter@tie{}0 (i.e. sharp corners)."
 Draw a box with rounded corners around @var{arg}.  Looks at @code{thickness},
 @code{box-padding} and @code{font-size} properties to determine line
 thickness and padding around the markup; the @code{corner-radius} property
-makes possible to define another shape for the corners (default is 1)." 
+makes possible to define another shape for the corners (default is 1).
+
+@lilypond[quote,verbatim,fragment,relative=2]
+c^\markup{ \rounded-box Overtura }
+c,8. c16 c4 r
+@end lilypond" 
   (let* ((th (*
              (ly:output-def-lookup layout 'line-thickness)
              (chain-assoc-get 'thickness props 1)))
index baa8fe8ccd626685b0f67e7e4da313a69fc0d1a8..3256d49f61e6140b229cf0d721548d0966348648 100644 (file)
@@ -134,11 +134,17 @@ encloses the contents.
 
   (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 thickness) (interval-widen yext thickness) blot))
+                  (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 
-       (cons (+ (car xext) thickness) (- (cdr xext) thickness)) 
-       (cons (+ (car yext) thickness) (- (cdr yext) thickness)) (* blot 0.8)))))))
+       (cons (+ (car xext) ideal-thickness) (- (cdr xext) ideal-thickness)) 
+       (cons (+ (car yext) ideal-thickness) (- (cdr yext) ideal-thickness)) 
+            (- ideal-blot (* ideal-thickness 2))))))))
     (set! stencil (ly:stencil-add outer inner))
     stencil))