blob: 9f3d5e5903d1549a9c3f92b4942c06662742d998 (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
%% 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.18.0"
\header {
= "rhythms, scheme-language, text"
= "
This example shows how to add a markup command to get a three sided box
around some text (or other markup).
"
= "Three-sided box"
} % begin verbatim
% 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
#(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 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},
@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)))
% Test it:
\relative c' {
c1^\markup { \NWS-box ABCD }
c1^\markup { \NWS-box \note #"4" #1.0 }
}
|