lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dashed initial barline with SystemStartBar?


From: Thomas Morley
Subject: Re: dashed initial barline with SystemStartBar?
Date: Sat, 2 Jun 2012 01:45:11 +0200

Hi,

2012/6/1 diekunstderfuge <address@hidden>:
>
> Hi all,
>
> I would like the barline printed by System_start_delimiter_engraver using
> SystemStartBar to print as a dashed barline instead of a solid barline.

it seems that the only available style is 'bar-line. But you can
override the stencil.

Some remarks:
(1)
I used an idea of David Nalesnik.
http://lists.gnu.org/archive/html/lilypond-user/2012-05/msg00209.html
Thanks again!!

(2)
In `factors' of `make-dashed-system-start-bar' there is a hardcoded
value, that I figured out manually: 0.983
I wasn't able to express this through a variable.
Any hint?

(3)
BTW, I was surprised that now \layout { \userDefinedCommand } is possible.
Your work David (Kastrup)?
So, thanks a lot (again)! Or to whoever made it possible.

(4)
Is it possible to turn a \with-command not only in a variable, but in
a function? I experimented with define-void-function but without
success.


The code:

%%%%%%%%%%%%%%%%%%%%%

\version "2.15.39"

%#(set-global-staff-size 32)

#(define (make-round-filled-box x1 x2 y1 y2 blot-diameter)
     (ly:make-stencil (list 'round-filled-box (- x1) x2 (- y1) y2 blot-diameter)
                      (cons x1 x2)
                      (cons y1 y2)))

#(define-public (make-dashed-system-start-bar grob extent thickness)
   (let* ((blot (ly:output-def-lookup (ly:grob-layout grob) 'blot-diameter))
          (line-thickness (ly:staff-symbol-line-thickness grob))
          (staff-space (ly:staff-symbol-staff-space grob))
          (height (interval-length extent))
          (dash-size (- 1.0 (ly:grob-property grob 'gap 0.5)))
          (num (ceiling (/ (* 1.5 height) (+ dash-size staff-space))))
          (factors
            (map
              (lambda (x) (+ (/ num 100)  (* 0.983  (/ height (1- (* 2
num))) x)))
              (iota (* 2 num))))
          (stencil (ly:stencil-add
                               (ly:stencil-translate-axis
                                (make-round-filled-box 0 thickness (/
dash-size -2) 0 blot)
                                (+ (interval-end extent)(* 0.5 line-thickness))
                                Y)
                               (ly:stencil-translate-axis
                                (make-round-filled-box 0 thickness 0
(/ dash-size 2) blot)
                                (- (interval-start extent) (* 0.5
line-thickness))
                                Y))))

        (define (helper args)
             (set! stencil
                (ly:stencil-add stencil
                     (ly:stencil-translate-axis
                      (make-round-filled-box 0 thickness
                                             (car args) (cadr args) blot)
                      (interval-start extent)
                      Y)))
             (if (null? (cddr args))
               stencil
               (helper (cddr args))))

  (if (zero? num)
            empty-stencil
            (helper factors))))

dashedStart =
\override Score.SystemStartBar #'stencil =
 #(lambda (grob)
  (let*((stencil (ly:system-start-delimiter::print grob))
        (stencil-y-extent (ly:stencil-extent stencil Y))
        (line-thickness (ly:staff-symbol-line-thickness grob))
        (new-stencil-extent (interval-widen stencil-y-extent (* -0.5
line-thickness)))
        (thickness (ly:grob-property grob 'thickness))
        (grob-thickness (* line-thickness thickness)))
  (make-dashed-system-start-bar grob new-stencil-extent grob-thickness)))

withMinusVI = \with {
                   fontSize = #-6
                   \override StaffSymbol #'staff-space = #(magstep -6)
                   \override StaffSymbol #'thickness = #(magstep -6)
           }

withPlusVI = \with {
                   fontSize = #6
                   \override StaffSymbol #'staff-space = #(magstep 6)
                   \override StaffSymbol #'thickness = #(magstep 6)
           }

mus = \relative c' {
        a'1 \break
        b \break
        a,, \break
        b''
}

\score {
      <<
        <<
           \new Staff \withMinusVI
           \mus
           \new Staff { \clef bass \mus }
           \new Staff { \clef bass \mus }
        >>
        \new StaffGroup
        <<
           \new Staff \mus
           \new Staff { \clef bass \mus }
           \new Staff \withPlusVI
           { \clef bass \mus }
        >>
      >>
        \layout {
                \dashedStart
        }
                
}

%%%%%%%%%%%%%%%%%%%%%

Cheers,
  Harm



reply via email to

[Prev in Thread] Current Thread [Next in Thread]