lilypond-user
[Top][All Lists]
Advanced

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

Re: dotted semicircle indicating harmonics


From: Pierre Perol-Schneider
Subject: Re: dotted semicircle indicating harmonics
Date: Sat, 7 Jul 2018 16:06:54 +0200

Also to avoid the 360° misscount :

%circled-pattern
#(define-markup-command
  (circled-pattern layout props radius angle num arg)
  (number? number? number? string?)
  (let* ((rep (if (eq? angle 360)(abs num)(- (abs num) 1)))
          (the-form
           (if (eq? num 0) (markup "")
            (if (eq? (abs num) 1) (markup arg)
            (markup
             (#:combine
              (#:null)
              (fold
               (lambda (i prev)
                (markup
                 (#:combine
                  (#:rotate
                   (* i (/ angle rep))
                   (#:concat (#:null #:hspace radius arg)))
                  prev)))
               (markup (#:null))
               (iota (1+ rep)))))))))
     (interpret-markup layout props the-form)))

testOne = \markup "."
testTwo = \markup \with-color #red "!"

\markup\circled-pattern #5 #180 #15 \testOne
\markup\circled-pattern #5 #-180 #15 \testOne
\markup\circled-pattern #5 #360 #4 \testOne

%\markup\circled-pattern #5 #360 #0 \testTwo

Cheers,
Pierre

2018-07-07 15:54 GMT+02:00 Pierre Perol-Schneider <address@hidden>:
Well, not sure actually, since it's problematic with 0, 1 , -1.
So how about :

%circled-pattern
#(define-markup-command
  (circled-pattern layout props radius angle num arg)
  (number? number? number? string?)
  (let* ((rep (- (abs num) 1))
          (the-form
           (if (eq? num 0) (markup "")
            (if (eq? (abs num) 1) (markup arg)
            (markup
             (#:combine
              (#:null)
              (fold
               (lambda (i prev)
                (markup
                 (#:combine
                  (#:rotate
                   (* i (/ angle rep))
                   (#:concat (#:null #:hspace radius arg)))
                  prev)))
               (markup (#:null))
               (iota (1+ rep)))))))))
     (interpret-markup layout props the-form)))

testOne = \markup "."
testTwo = \markup { \rotate #45 "!" }

\markup\circled-pattern #5 #180 #15 \testOne
\markup\circled-pattern #5 #-180 #15 \testOne
\markup\circled-pattern #5 #180 #2 \testOne
\markup\circled-pattern #5 #180 #1 \testOne
\markup\circled-pattern #5 #180 #0 \testOne

%\markup\circled-pattern #5 #360 #5 \testTwo

Plus : any idea why 'testTwo does not work ?

Cheers,
Pierre

2018-07-07 15:35 GMT+02:00 Orm Finnendahl <address@hiddenfrankfurt.de>:
Hi List,

 for conciseness the example should be reduced even more (if someone
wants to post it to LSR I'd recommend this version).

%circled-pattern
#(define-markup-command
  (circled-pattern layout props radius angle num arg)
  (number? number? number? string?)
  (interpret-markup layout props
   (fold
    (lambda (i prev)
     (markup
      (#:combine
       (#:rotate
        (* i (/ angle num))
        (#:concat (#:null #:hspace radius arg)))
       prev)))
    (markup (#:null))
    (iota (1+ num))))))

% Test (markup a 180° circled pattern with radius 5 and 17 dots) :
\markup\circled-pattern #5 #180 #16 #"."

% an upside down pattern can be achieved with a negative angle:

\markup\circled-pattern #5 #-180 #16 #"."



reply via email to

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