1 %% DO NOT EDIT this file manually; it is automatically
2 %% generated from LSR http://lsr.dsi.unimi.it
3 %% Make any changes in LSR itself, or in Documentation/snippets/new/ ,
4 %% and then run scripts/auxiliar/makelsr.py
6 %% This file is in the public domain.
10 lsrtags = "text, rhythms, scheme-language"
13 This example shows how to add a markup command to get a three sided box
14 around some text (or other markup).
17 doctitle = "Three-sided box"
21 % New command to add a three sided box, with sides north, west and south
22 % Based on the box-stencil command defined in scm/stencil.scm
23 % Note that ";;" is used to comment a line in Scheme
24 #(define-public (NWS-box-stencil stencil thickness padding)
25 "Add a box around STENCIL, producing a new stencil."
26 (let* ((x-ext (interval-widen (ly:stencil-extent stencil X) padding))
27 (y-ext (interval-widen (ly:stencil-extent stencil Y) padding))
28 (y-rule (make-filled-box-stencil (cons 0 thickness) y-ext))
29 (x-rule (make-filled-box-stencil
30 (interval-widen x-ext thickness) (cons 0 thickness))))
31 ;; (set! stencil (ly:stencil-combine-at-edge stencil X 1 y-rule padding))
32 (set! stencil (ly:stencil-combine-at-edge stencil X LEFT y-rule padding))
33 (set! stencil (ly:stencil-combine-at-edge stencil Y UP x-rule 0.0))
34 (set! stencil (ly:stencil-combine-at-edge stencil Y DOWN x-rule 0.0))
37 % The corresponding markup command, based on the \box command defined
38 % in scm/define-markup-commands.scm
39 #(define-markup-command (NWS-box layout props arg) (markup?)
40 "Draw a box round @var{arg}. Looks at @code{thickness},
41 @code{box-padding} and @code{font-size} properties to determine line
42 thickness and padding around the markup."
43 (let* ((th (chain-assoc-get 'thickness props 0.1))
44 (size (chain-assoc-get 'font-size props 0))
45 (pad (* (magstep size)
46 (chain-assoc-get 'box-padding props 0.2)))
47 (m (interpret-markup layout props arg)))
48 (NWS-box-stencil m th pad)))
53 c1^\markup { \NWS-box ABCD }
54 c1^\markup { \NWS-box \note #"4" #1.0 }