lilypond-user
[Top][All Lists]
Advanced

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

Re: Using Scheme inside Lilypond


From: Jean Abou Samra
Subject: Re: Using Scheme inside Lilypond
Date: Sat, 4 Sep 2021 22:21:50 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0

Le 04/09/2021 à 20:39, Richard Shann a écrit :
(I'm trying to write code that will draw a box round A4 or letter paper
with just a change of some scaling factors - I can work around it but
it's distressing not to understand what is going on).

Is this the kind of thing you're looking for?

\version "2.22.1"

#(define-markup-command (page-box layout props left-padding top-padding right-padding bottom-padding)
   (number? number? number? number?)
   #:properties ((thickness 0.1))
   (let* ((paper-width (ly:output-def-lookup layout 'paper-width))
          (paper-height (ly:output-def-lookup layout 'paper-height))
          (left-margin (ly:output-def-lookup layout 'left-margin))
          (top-margin (ly:output-def-lookup layout 'top-margin))
          (start-x (- left-padding left-margin))
          (start-y (- (- top-padding top-margin)))
          (end-x (- paper-width right-padding left-margin))
          (end-y (- (- paper-height bottom-padding top-margin))))
     (ly:stencil-outline
       (interpret-markup layout props
         (make-path-markup
           thickness
           `((moveto ,start-x ,start-y)
             (lineto ,start-x ,end-y)
             (lineto ,end-x ,end-y)
             (lineto ,end-x ,start-y)
             (closepath))))
       empty-stencil)))

\paper {
  #(set-paper-size "a5landscape")
}

\markup \combine
  \override #'(thickness . 0.3) \page-box #2 #2 #3 #1
  \page-box #3 #3 #4 #2



Best,
Jean



reply via email to

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