10.04.2013 Views

in Snippets - LilyPond

in Snippets - LilyPond

in Snippets - LilyPond

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Rhythms 59<br />

be set to a fraction giv<strong>in</strong>g the duration of the beam sub-group us<strong>in</strong>g the ly:make-moment function,<br />

as shown <strong>in</strong> this snippet. Also, when baseMoment is changed, beatStructure should also<br />

be changed to match the new baseMoment:<br />

\relative c'' {<br />

c32[ c c c c c c c]<br />

\set subdivideBeams = ##t<br />

c32[ c c c c c c c]<br />

}<br />

% Set beam sub-group length to an eighth note<br />

\set baseMoment = #(ly:make-moment 1 8)<br />

\set beatStructure = #'(2 2 2 2)<br />

c32[ c c c c c c c]<br />

% Set beam sub-group length to a sixteenth note<br />

\set baseMoment = #(ly:make-moment 1 16)<br />

\set beatStructure = #'(4 4 4 4)<br />

c32[ c c c c c c c]<br />

<br />

<br />

<br />

Three-sided box<br />

This example shows how to add a markup command to get a three sided box around some text<br />

(or other markup).<br />

% New command to add a three sided box, with sides north, west and south<br />

% Based on the box-stencil command def<strong>in</strong>ed <strong>in</strong> scm/stencil.scm<br />

% Note that ";;" is used to comment a l<strong>in</strong>e <strong>in</strong> Scheme<br />

#(def<strong>in</strong>e-public (NWS-box-stencil stencil thickness padd<strong>in</strong>g)<br />

"Add a box around STENCIL, produc<strong>in</strong>g a new stencil."<br />

(let* ((x-ext (<strong>in</strong>terval-widen (ly:stencil-extent stencil X) padd<strong>in</strong>g))<br />

(y-ext (<strong>in</strong>terval-widen (ly:stencil-extent stencil Y) padd<strong>in</strong>g))<br />

(y-rule (make-filled-box-stencil (cons 0 thickness) y-ext))<br />

(x-rule (make-filled-box-stencil<br />

(<strong>in</strong>terval-widen x-ext thickness) (cons 0 thickness))))<br />

;; (set! stencil (ly:stencil-comb<strong>in</strong>e-at-edge stencil X 1 y-rule padd<strong>in</strong>g))<br />

(set! stencil (ly:stencil-comb<strong>in</strong>e-at-edge stencil X LEFT y-rule padd<strong>in</strong>g))<br />

(set! stencil (ly:stencil-comb<strong>in</strong>e-at-edge stencil Y UP x-rule 0.0))<br />

(set! stencil (ly:stencil-comb<strong>in</strong>e-at-edge stencil Y DOWN x-rule 0.0))<br />

stencil))<br />

% The correspond<strong>in</strong>g markup command, based on the \box command def<strong>in</strong>ed<br />

% <strong>in</strong> scm/def<strong>in</strong>e-markup-commands.scm<br />

#(def<strong>in</strong>e-markup-command (NWS-box layout props arg) (markup?)<br />

"Draw a box round @var{arg}. Looks at @code{thickness},<br />

@code{box-padd<strong>in</strong>g} and @code{font-size} properties to determ<strong>in</strong>e l<strong>in</strong>e<br />

thickness and padd<strong>in</strong>g around the markup."<br />

(let* ((th (cha<strong>in</strong>-assoc-get 'thickness props 0.1))<br />

(size (cha<strong>in</strong>-assoc-get 'font-size props 0))<br />

(pad (* (magstep size)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!