[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Combining NoteHead and Stem stencils for rotation
From: |
address@hidden |
Subject: |
Re: Combining NoteHead and Stem stencils for rotation |
Date: |
Tue, 29 Mar 2011 10:26:54 -0400 |
On Mar 29, 2011, at 9:25 AM, David Kastrup wrote:
> address@hidden writes:
>
>> Hey all,
>>
>> I'd like to rotate a note head and its stem in one fell swoop.
>>
>> This seems rather nightmarish to do. I can envision two solutions:
>>
>> (1) Combine the stem stencil with its notehead stencil and then make
>> the notehead transparent. Then, rotate this uberstencil.
>> (2) Do trig on the stem to translate it after having rotated the
>> notehead (or vice versa).
>>
>> Both of these options seem not easy, but option 2 seems more feasible.
>> In order to do this, though, I'd have to spend a fair bit of time
>> doing the math and work with different unit systems for X and Y (I
>> think).
>>
>> Before I start on this, can anyone think of a quick & easy way to do
>> this rotation?
>
> 2 seems rather trivial. Note that rotation about (x,y) is the same as
> subtracting (x,y), rotating about (0,0), and then adding (x,y). So it
> should be easy enough, given the rotation of one element, to make
> another rotate in a shifted coordinate system.
The difficulty I had with this is that I get the sense that noteheads cannot be
separately translated.
#(define (goo grob)
(let* ((refpy (ly:grob-common-refpoint grob (ly:grob-parent grob Y) Y))
(coord-y (ly:grob-relative-coordinate grob refpy Y))
(rad (+ coord-y 2.5))
(angle (degrees->radians 15))
(x-trans (* rad (cos angle)))
(y-trans (- (* rad (sin angle))))
(stencil (ly:note-head::print grob)))
(ly:stencil-translate (ly:stencil-rotate stencil 15 -1 -1) (cons
x-trans y-trans))))
\relative c' {
\override Stem #'stencil = ##f <\tweak #'stencil #goo d \tweak #'stencil #goo f
\tweak #'stencil #goo a>8
}
You'll see that the three noteheads never translate in their X dimension. I'm
suspecting that the note column tries to keep them in line. Is there a
workaround for this without messing with stencil extents?
Cheers,
MS