Guys,

this is driving me crazy. I responded to a
request on -user for a "torn-page" effect at 
the end of each system, preferably random. I
made some progress, then slammed head-first
into inexplicable buggy behavior. I tried to
recreate this on a smaller scale, but this 
is as small as I can get it.

I'm using a template of sorts to create the
torn-page effect (for the right side of the 
staff first) called "rightTearGeneric".

Using that, I made 3 flavors: rightTearFixed 
(creates the same tear each time), 
rightTearCustom (pass it a list of staff-line
tear-lengths each time), and rightTearRandom 
(automated). 

Bizarrely, they all work some of the time!
It seems to depend on the order in which they
appear. Example: random-fixed-fixed-fixed
works, but random-fixed-fixed-fixed-fixed
fails, and even stranger, it only fails on 
the 2nd of the 4 "fixed"s.

This specific project isn't the point. I've
come across this strangeness before, and I
don't ever want to hit this again.

HEEEELLLLLPP!!!!

- Mark


      
\version "2.12.0"

rightTearWidth = #1
rightTearFixedLengths = #'(0 1 3 4 2)

rightTearGeneric =
  #(define-music-function (parser location lengths) (list?)
  #{
    #(define (x-ext n)
             (cons (* (list-ref $lengths n) (/ rightTearWidth 4)) rightTearWidth))
    #(define y-ext '(1.5 . 2.5))

    \once \override Staff.BarLine #'stencil = #ly:text-interface::print
    \once \override Staff.BarLine #'text = \markup
      \override #'(baseline-skip . 0) \with-color #white
      \column {
        \filled-box #(x-ext 0) #y-ext #0
        \filled-box #(x-ext 1) #y-ext #0
        \filled-box #(x-ext 2) #y-ext #0
        \filled-box #(x-ext 3) #y-ext #0
        \filled-box #(x-ext 4) #y-ext #0
      }
    \once \override Staff.BarLine #'X-extent = #(cons 0 (- rightTearWidth 0.1))
    \break
  #} )

rightTearFixed =
  #(define-music-function (parser location) ()
  #{ \rightTearGeneric \rightTearFixedLengths #} )

rightTearCustom =
  #(define-music-function (parser location lengths) (list?)
  #{ \rightTearGeneric #$lengths #} )

rightTearRandom =
  #(define-music-function (parser location) ()
  #{ \rightTearGeneric
    #(list (random 5) (random 5) (random 5) (random 5) (random 5)) #} )



\score {
  \relative {
    g'4 d' b d \rightTearRandom
    g,4 d' b d \rightTearFixed
    g,4 d' b d \rightTearFixed
    g,4 d' b d \rightTearFixed
    g,4 d' b d \rightTearFixed
  }
  \layout {
    indent = #0
    ragged-right = ##t
  }
}

<<attachment: torn-staves_3.png>>

_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-devel

Reply via email to