[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Centering a stencil on another stencil
From: |
Thomas Morley |
Subject: |
Re: Centering a stencil on another stencil |
Date: |
Thu, 13 Aug 2015 21:43:55 +0200 |
Hi Paul,
2015-08-13 19:50 GMT+02:00 Paul Morris <address@hidden>:
> Here’s another possibility that uses an optional axis argument. -Paul
>
> \version "2.19.22"
>
> #(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} is 0 for X axis, 1 for Y axis."
> (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))
> }
I like this best and would go for it.
Regretable my vacations ended. Meaning I've reasonable less time :(
Cheers,
Harm
- Re: Centering a stencil on another stencil, Paul Morris, 2015/08/07
- Re: Centering a stencil on another stencil, Thomas Morley, 2015/08/07
- Re: Centering a stencil on another stencil, Paul Morris, 2015/08/10
- Re: Centering a stencil on another stencil, Thomas Morley, 2015/08/11
- Re: Centering a stencil on another stencil, Paul Morris, 2015/08/11
- Re: Centering a stencil on another stencil, Thomas Morley, 2015/08/11
- Re: Centering a stencil on another stencil, Thomas Morley, 2015/08/11
- Re: Centering a stencil on another stencil, Paul Morris, 2015/08/12
- Re: Centering a stencil on another stencil, Paul Morris, 2015/08/13
- Re: Centering a stencil on another stencil,
Thomas Morley <=
- Re: Centering a stencil on another stencil, Paul Morris, 2015/08/13
- Re: Centering a stencil on another stencil, Thomas Morley, 2015/08/13