X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=Documentation%2Fsnippets%2Fthree-sided-box.ly;h=3e1080dcb73bf4bd0318243f8e98fc7f6890f46d;hb=730d4eb3e0328e8ba0b376f8191a5bb6ae7f904c;hp=baf2a06f611d4d7bc6ee9304849e25e6a52e59d7;hpb=71243e9548e9146da4a90e6347dbca6430346be8;p=lilypond.git diff --git a/Documentation/snippets/three-sided-box.ly b/Documentation/snippets/three-sided-box.ly index baf2a06f61..3e1080dcb7 100644 --- a/Documentation/snippets/three-sided-box.ly +++ b/Documentation/snippets/three-sided-box.ly @@ -1,10 +1,13 @@ -%% Do not edit this file; it is automatically -%% generated from LSR http://lsr.dsi.unimi.it +%% DO NOT EDIT this file manually; it is automatically +%% generated from LSR http://lsr.di.unimi.it +%% Make any changes in LSR itself, or in Documentation/snippets/new/ , +%% and then run scripts/auxiliar/makelsr.py +%% %% This file is in the public domain. -\version "2.13.4" +\version "2.18.0" \header { - lsrtags = "rhythms, text" + lsrtags = "rhythms, scheme-language, text" texidoc = " This example shows how to add a markup command to get a three sided box @@ -16,38 +19,36 @@ around some text (or other markup). % New command to add a three sided box, with sides north, west and south % Based on the box-stencil command defined in scm/stencil.scm -% Note that ";" is used to comment a line in Scheme +% Note that ";;" is used to comment a line in Scheme #(define-public (NWS-box-stencil stencil thickness padding) - "Add a box around STENCIL, producing a new stencil." - (let* ((x-ext (interval-widen (ly:stencil-extent stencil 0) padding)) - (y-ext (interval-widen (ly:stencil-extent stencil 1) padding)) - (y-rule (make-filled-box-stencil (cons 0 thickness) y-ext)) - (x-rule (make-filled-box-stencil - (interval-widen x-ext thickness) (cons 0 thickness)))) -; (set! stencil (ly:stencil-combine-at-edge stencil X 1 y-rule padding)) - (set! stencil (ly:stencil-combine-at-edge stencil X -1 y-rule padding)) - (set! stencil (ly:stencil-combine-at-edge stencil Y 1 x-rule 0.0)) - (set! stencil (ly:stencil-combine-at-edge stencil Y -1 x-rule 0.0)) - stencil)) + "Add a box around STENCIL, producing a new stencil." + (let* ((x-ext (interval-widen (ly:stencil-extent stencil X) padding)) + (y-ext (interval-widen (ly:stencil-extent stencil Y) padding)) + (y-rule (make-filled-box-stencil (cons 0 thickness) y-ext)) + (x-rule (make-filled-box-stencil + (interval-widen x-ext thickness) (cons 0 thickness)))) + ;; (set! stencil (ly:stencil-combine-at-edge stencil X 1 y-rule padding)) + (set! stencil (ly:stencil-combine-at-edge stencil X LEFT y-rule padding)) + (set! stencil (ly:stencil-combine-at-edge stencil Y UP x-rule 0.0)) + (set! stencil (ly:stencil-combine-at-edge stencil Y DOWN x-rule 0.0)) + stencil)) % The corresponding markup command, based on the \box command defined % in scm/define-markup-commands.scm #(define-markup-command (NWS-box layout props arg) (markup?) - "Draw a box round @var{arg}. Looks at @code{thickness}, + "Draw a box round @var{arg}. Looks at @code{thickness}, @code{box-padding} and @code{font-size} properties to determine line thickness and padding around the markup." - (let* ((th (chain-assoc-get 'thickness props 0.1)) - (size (chain-assoc-get 'font-size props 0)) - (pad (* (magstep size) - (chain-assoc-get 'box-padding props 0.2))) - (m (interpret-markup layout props arg))) - (NWS-box-stencil m th pad))) + (let* ((th (chain-assoc-get 'thickness props 0.1)) + (size (chain-assoc-get 'font-size props 0)) + (pad (* (magstep size) + (chain-assoc-get 'box-padding props 0.2))) + (m (interpret-markup layout props arg))) + (NWS-box-stencil m th pad))) % Test it: -\layout { ragged-right = ##f } \relative c' { - c2^\markup { \NWS-box ABCD } - c2^\markup { \NWS-box \note #"4" #1.0 } + c1^\markup { \NWS-box ABCD } + c1^\markup { \NWS-box \note #"4" #1.0 } } -