]> git.donarmstrong.com Git - lilypond.git/blob - input/lsr/three-sided-box.ly
Fix makelsr.py and update LSR
[lilypond.git] / input / lsr / three-sided-box.ly
1 %% Do not edit this file; it is auto-generated from LSR http://lsr.dsi.unimi.it
2 %% This file is in the public domain.
3 %% Tags: editorial-and-educational-use
4 \version "2.11.35"
5
6 \header { texidoc = "
7 This example shows how to add a markup command to get a three sided box
8 around some text (or other markup).
9 " }
10 % begin verbatim
11 % New command to add a three sided box, with sides north, west and south
12 % Based on the box-stencil command defined in scm/stencil.scm
13 % Note that you use ";" to comment a line in Scheme
14 #(define-public (NWS-box-stencil stencil thickness padding)
15   "Add a box around STENCIL, producing a new stencil."
16   (let* ((x-ext (interval-widen (ly:stencil-extent stencil 0) padding))
17          (y-ext (interval-widen (ly:stencil-extent stencil 1) padding))
18          (y-rule (make-filled-box-stencil (cons 0 thickness) y-ext))
19          (x-rule (make-filled-box-stencil
20                   (interval-widen x-ext thickness) (cons 0 thickness))))
21 ;    (set! stencil (ly:stencil-combine-at-edge stencil X 1 y-rule padding))
22     (set! stencil (ly:stencil-combine-at-edge stencil X -1 y-rule padding))
23     (set! stencil (ly:stencil-combine-at-edge stencil Y 1 x-rule 0.0))  
24     (set! stencil (ly:stencil-combine-at-edge stencil Y -1 x-rule 0.0))
25     stencil))
26
27 % The corresponding markup command, based on the \box command defined 
28 % in scm/define-markup-commands.scm
29 #(define-markup-command (NWS-box layout props arg) (markup?)
30   "Draw a box round @var{arg}.  Looks at @code{thickness},
31 @code{box-padding} and @code{font-size} properties to determine line
32 thickness and padding around the markup."
33   
34   (let* ((th (chain-assoc-get 'thickness props  0.1))
35          (size (chain-assoc-get 'font-size props 0))
36          (pad (* (magstep size)
37                  (chain-assoc-get 'box-padding props 0.2)))
38          (m (interpret-markup layout props arg)))
39     (NWS-box-stencil m th pad)))
40
41
42 % Test it:
43
44 \relative c'{ 
45   c^\markup{ \NWS-box ABCD }
46   c^\markup{\NWS-box \note #"4" #1.0 } 
47 }