lilypond-user
[Top][All Lists]
Advanced

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

Re: What to do wanting a 4th order Bézier?


From: Simon Albrecht
Subject: Re: What to do wanting a 4th order Bézier?
Date: Sat, 17 Sep 2016 23:10:08 +0200

And finally with a better user interface:

%%%%%%%%%%%%%%%%%%%%%%%%
\version "2.19.47"
\language "deutsch"
#(define (make-cross-stencil coord)
   "Draw a cross-stencil at coord."
   (let ((thick 0.1)
         (sz 0.2))
     (stencil-with-color
      (ly:stencil-add
       (make-line-stencil
        thick
        (- (car coord) sz)
        (- (cdr coord) sz)
        (+ (car coord) sz)
        (+ (cdr coord) sz))
       (make-line-stencil
        thick
        (- (car coord) sz)
        (+ (cdr coord) sz)
        (+ (car coord) sz)
        (- (cdr coord) sz)))

      cyan)
     ))
compoundSlur =
#(define-event-function (contr-pts ann?) (list? boolean?)
   (let ((proc (lambda (grob)
                 (let*  (;; only here for reference:
                          (cps (ly:slur::calc-control-points grob))
                          (cps1 (first contr-pts))
                          (cps2 (second contr-pts))
                          (first-spline-stil
                           (begin
(ly:grob-set-property! grob 'control-points cps1)
                            (ly:slur::print grob)))
                          (second-spline-stil
                           (begin
(ly:grob-set-property! grob 'control-points cps2)
                            (ly:slur::print grob)))
                          ;; annotates all new control-points
                          (crosses
                           (if ann?
                               (apply
                                ly:stencil-add
                                (map
                                 (lambda (c)
                                   (make-cross-stencil c))
                                 (append cps1 cps2)))
                               empty-stencil))
                          )
                   ;(pretty-print cps)
                   ;; returns
                   ;;  ((0.631380973009261 . 7.545004)
                   ;;   (3.65053718406404 . 9.82511349243875)
                   ;;   (53.1972252988833 . 16.0566485774538)
                   ;;   (56.6869647738747 . 14.5951692170292))

                   (ly:stencil-add
                    first-spline-stil
                    second-spline-stil
                    crosses
                    )))))
     #{ -\tweak stencil $proc ( #}))
cptsA = #'(((0.6 . 5.8)
            (3.6 . 7.8)
            (25.0 . 5.0)
            (32 . 12))
           ((32 . 12)
            (39.0 . 17.5)
            (53.1 . 16.0)
            (55.5 . 12.5)))

upper = \relative {
  \key d \major
  \clef bass
  s2 r8 d,16 g h d g h
  d8 r s2.
  s4 \voiceTwo h8.(-- c16-- h2--)
}
lower = \relative {
  \key d \major
  \clef bass
  r2
  <d' h g=>~-^-\compoundSlur \cptsA ##t
  <<
    {
      <d h g>4 <c g e> <h g> \voiceOne cis
      \change Staff = upper
      \clef treble \voiceOne d e fis2)
      \fermata
    }
    \new Voice {
      \voiceTwo
      s2. <g,= e>4 \oneVoice
      <fis h,> <g e> <fis dis>2\fermata
    }
  >>
}
\score {
  <<
    \new PianoStaff <<
      \new Staff = upper \upper
      \new Staff = lower \lower
    >>
  >>
}
%%%%%%%%%%%%%%%%%%%%%%%

Thanks a lot!
Simon


On 17.09.2016 22:39, Thomas Morley wrote:
2016-09-17 21:50 GMT+02:00 Simon Albrecht <address@hidden>:

Only one glitch: Is make-cross-stencil a private function of yours?
Aaarrrgh, forgot to include. Sorry for that.

#(define (make-cross-stencil coord)
   "Draw a cross-stencil at coord."
   (let ((thick 0.1)
         (sz 0.2))
   (stencil-with-color
     (ly:stencil-add
       (make-line-stencil
         thick
         (- (car coord) sz)
         (- (cdr coord) sz)
         (+ (car coord) sz)
         (+ (cdr coord) sz))
       (make-line-stencil
         thick
         (- (car coord) sz)
         (+ (cdr coord) sz)
         (+ (car coord) sz)
         (- (cdr coord) sz)))

   cyan)
   ))

Cheers,
   Harm




reply via email to

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