[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Using Scheme inside Lilypond
From: |
Richard Shann |
Subject: |
Re: Using Scheme inside Lilypond |
Date: |
Sun, 05 Sep 2021 11:41:06 +0100 |
On Sat, 2021-09-04 at 22:21 +0200, Jean Abou Samra wrote:
> 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
That's very kind of you - I would have slogged away for a day or two to
generate something not even half as general and elegant. I'll slot that
in...
Richard