From: Thomas Morley Date: Tue, 13 Oct 2015 17:31:06 +0000 (+0200) Subject: simplify `make-bezier-stencil' X-Git-Tag: release/2.19.30-1~5^2~4 X-Git-Url: https://git.donarmstrong.com/?p=lilypond.git;a=commitdiff_plain;h=7b5ff8ac30bccd7c31954d6fffeb0cf333fd9d4f simplify `make-bezier-stencil' issue 4637 Use `make-path-stencil' for it. As a consequence `make-curved-barre-stencil' from scm/fretdiagrams.scm is simplified as well. `make-parenthesis-stencil' in scm/stencil.scm a little bit, at least. --- diff --git a/scm/fret-diagrams.scm b/scm/fret-diagrams.scm index 85cfbb9b36..3b0990cf41 100644 --- a/scm/fret-diagrams.scm +++ b/scm/fret-diagrams.scm @@ -405,17 +405,17 @@ baseline at fret coordinate @var{base}, a height of bottom-control-point-height cp-right-width))) ;; order of bezier control points is: - ;; left cp low, right cp low, right end low, left end low - ;; right cp high, left cp high, left end high, right end high. + ;; left cp low, left cp low, right cp low, right end low + ;; right cp high, left cp high - (list left-lower-control-point + (list + left-end-point + left-lower-control-point right-lower-control-point right-end-point - left-end-point + right-upper-control-point - left-upper-control-point - left-end-point - right-end-point))) + left-upper-control-point))) (define (draw-strings) "Draw the string lines for a fret diagram with @@ -564,24 +564,10 @@ fret-diagram overall parameters." (* size end-string-coordinate) (* size fret-coordinate) (* size bezier-height) - (* size bezier-thick))) - (box-lower-left - (stencil-coordinates - (+ (* size fret-coordinate) half-thickness) - (- (* size start-string-coordinate) half-thickness))) - (box-upper-right - (stencil-coordinates - (- (* size fret-coordinate) - (* size bezier-height) - half-thickness) - (+ (* size end-string-coordinate) half-thickness))) - (x-extent (cons (car box-lower-left) (car box-upper-right))) - (y-extent (cons (cdr box-lower-left) (cdr box-upper-right)))) + (* size bezier-thick)))) (make-bezier-sandwich-stencil bezier-list - (* size bezier-thick) - x-extent - y-extent))) + (* size bezier-thick)))) (define (draw-dots dot-list) "Make dots for fret diagram." diff --git a/scm/stencil.scm b/scm/stencil.scm index fb2809e9fd..6410eae44c 100644 --- a/scm/stencil.scm +++ b/scm/stencil.scm @@ -15,29 +15,30 @@ ;;;; You should have received a copy of the GNU General Public License ;;;; along with LilyPond. If not, see . -(define (make-bezier-sandwich-stencil coords thick xext yext) - (let* ((command-list `(moveto - ,(car (list-ref coords 3)) - ,(cdr (list-ref coords 3)) - curveto - ,(car (list-ref coords 0)) - ,(cdr (list-ref coords 0)) - ,(car (list-ref coords 1)) - ,(cdr (list-ref coords 1)) - ,(car (list-ref coords 2)) - ,(cdr (list-ref coords 2)) - curveto - ,(car (list-ref coords 4)) - ,(cdr (list-ref coords 4)) - ,(car (list-ref coords 5)) - ,(cdr (list-ref coords 5)) - ,(car (list-ref coords 6)) - ,(cdr (list-ref coords 6)) - closepath))) - (ly:make-stencil - `(path ,thick `(,@' ,command-list) 'round 'round #t) - xext - yext))) +(define (make-bezier-sandwich-stencil coords thick) + (make-path-stencil + `(moveto + ,(car (list-ref coords 0)) + ,(cdr (list-ref coords 0)) + curveto + ,(car (list-ref coords 1)) + ,(cdr (list-ref coords 1)) + ,(car (list-ref coords 2)) + ,(cdr (list-ref coords 2)) + ,(car (list-ref coords 3)) + ,(cdr (list-ref coords 3)) + curveto + ,(car (list-ref coords 4)) + ,(cdr (list-ref coords 4)) + ,(car (list-ref coords 5)) + ,(cdr (list-ref coords 5)) + ,(car (list-ref coords 0)) + ,(cdr (list-ref coords 0)) + closepath) + thick + 1 + 1 + #t)) (define-public (stack-stencils axis dir padding stils) "Stack stencils @var{stils} in direction @var{axis}, @var{dir}, using @@ -142,26 +143,24 @@ the more angular the shape of the parenthesis." (cons inner-control-x upper-control-y)) (lower-inner-control-point (cons inner-control-x lower-control-y))) - - (make-bezier-sandwich-stencil - (list - ;; Step 4: curve through inner control points - ;; to lower end point. - upper-inner-control-point - lower-inner-control-point - lower-end-point - ;; Step 3: move to upper end point. - upper-end-point - ;; Step 2: curve through outer control points - ;; to upper end point. - lower-outer-control-point - upper-outer-control-point - upper-end-point - ;; Step 1: move to lower end point. - lower-end-point) - (min (* 2 half-thickness) line-width) - (interval-widen x-extent (/ line-width 2)) - (interval-widen y-extent (/ line-width 2))))) + (ly:make-stencil + (ly:stencil-expr + (make-bezier-sandwich-stencil + (list + ;; Step 1: move to lower end point. + lower-end-point + ;; Step 2: curve through outer control points + ;; to upper end point. + lower-outer-control-point + upper-outer-control-point + upper-end-point + ;; Step 3: curve through inner control points + ;; to lower end point. + upper-inner-control-point + lower-inner-control-point) + (min (* 2 half-thickness) line-width))) + (interval-widen x-extent (/ line-width 2)) + (interval-widen y-extent (/ line-width 2))))) (define-public (parenthesize-stencil stencil half-thickness width angularity padding)