Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
LilyPond wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Centering a stencil on another stencil
Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
If you want to re-position a stencil so that it is centered relative to another stencil, on the X axis, the Y axis, or both, you can use the "center-stencil-on-stencil" function from this snippet. <lilypond version="2.24.0"> #(define* (center-stencil-on-stencil stil-a stil-b #:optional axis) "Return a copy of stencil @var{stil-b} that has been moved so it is centered on stencil @var{stil-a} on @var{axis}. When @var{axis} is omitted, the centering is done on both X and Y axes. @var{axis} can be X or Y, which are equivalent to 0 and 1." (if axis ;; center on one axis only (ly:stencil-translate-axis (ly:stencil-aligned-to stil-b axis CENTER) (interval-center (ly:stencil-extent stil-a axis)) axis) ;; center on both X and Y axes (ly:stencil-translate (centered-stencil stil-b) (cons (interval-center (ly:stencil-extent stil-a X)) (interval-center (ly:stencil-extent stil-a Y)))))) square = #(make-connected-path-stencil '((0 0) (4 0) (4 4) (0 4) (0 0)) 0.4 1 1 #f #f) blue-square = #(stencil-with-color (make-filled-box-stencil '(0.4 . 2) '(0.4 . 2)) blue) \markup \override #'(word-space . 3) \line { \stencil #(ly:stencil-add square blue-square) \stencil #(ly:stencil-add square (center-stencil-on-stencil square blue-square X)) \stencil #(ly:stencil-add square (center-stencil-on-stencil square blue-square Y)) \stencil #(ly:stencil-add square (center-stencil-on-stencil square blue-square)) } </lilypond> [[Category:Scheme]] [[Category:Symbols and glyphs]]
Summary:
Please note that all contributions to LilyPond wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Meta:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Centering a stencil on another stencil
Add topic