bug-lilypond
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tweaking Hairpin shape


From: Stefano Troncaro
Subject: Re: Tweaking Hairpin shape
Date: Sun, 11 Feb 2018 18:44:10 -0300

I managed to fix it. The problem was not with the calculation of the angle,
it was with the translation of the angle to the offset that the function
applies to the vertical placement of the end-points of the hairpins. It is
correct now.

I also got rid of the rotation of the stencil for the case where the
straight end-points are not needed, the coordinates of the end-points for
the different cases are all calculated now.

As far as I can tell this is done. Finally!

I got the alists working now. I can't reproduce the problems I had earlier,
and the error message was weird and I don't remember it. But I guess that's
not important anymore.

I'm not sure I understood the following:

> But the spanner is cloned for each broken segment, so you aren't
> actually comparing
> with the initial bit.  Each new segment is simply drawn with a stencil
> reflecting its
> position within the whole.
>

By reading the code that creates the hairpin stencils I got the idea that
after line breaks are calculated, hairpins get broken into smaller hairpins
that are related to each other. And when drawing the stencils, if these
relationships are found, then they are drawn differently (they can start
and end in 1/3rd or 2/3rds of the height depending on the situation). If
what I'm saying is redundant with what you are saying, as I think it is,
then I probably did a poor job of explaining myself in my last message.
English is not my native language and I struggle to be clear and concise
with technical topics such as these. I apologize for the difficulties in
communication that surely arise because of this.

But why rotate it in the first place?
>
The case where one of the hairpin lines follows the staff lines would have
been much more easier to manage like you propose, that's without question.
However, I wanted to implement the whole rotation thing as an interface so
that in the future I can create functions that find the correct angle for
use cases that arise. The "follow the staff line" case was a way to test
this approach, and it made me find errors in the math, so it payed off in
the end.

I can now very comfortably get the hairpins I wanted, and I learned a lot
of useful things in the process. I know I said it many times already but
I'm truly grateful for your help! I never would have been able to reach a
satisfying solution without it.


2018-02-10 15:02 GMT-03:00 David Nalesnik <address@hidden>:

> Hi Stefano,
>
> On Sat, Feb 10, 2018 at 11:14 AM, Stefano Troncaro
> <address@hidden> wrote:
> > Hi David, thank you for your suggestions, this is almost done!
> >
> > I decided to pass an alist to the function instead of changing the
> amount of
> > arguments based on the procedure name, mainly because if I write more
> angle
> > functions in the future I want to be able to do so without having to
> temper
> > with the stencil definition. That is however a useful idea that I would
> have
> > never thought about, and I may find it useful in the future.
> >
> > I have a few doubts if you don't mind.
> >
> > 1) At first I couldn't make the alist approach work because for some
> reason
> > I can't define one in a let or let* block. Do you know why? I googled
> and I
> > couldn't find an explanation.
> >
> > 2) Is there a way to define an alist different than a succession of
> acons? I
> > thought I would be able to create it with a syntax like '((k1 . v1) (k2 .
> > v2) ... etc) but in the end I had to settle for (acons k1 v1 (acons k2 v2
> > ... (acons kn vn '()))).
>
> Not sure what you could have been doing wrong, but there are two ways you
> could
> define the alist
>
> (list (cons 'grob grob) (cons 'width width) (cons 'starth starth)
> (cons 'endh endh))
>
> or through quasi-quoting:
>
>  `((grob . ,grob) (width . ,width) (starth . ,starth) (endh . ,endh))
>
>
> > 3) I made the following function to make it so that the upper line of the
> > hairpin runs parallel with the staff lines. It does so by finding the
> angle
> > that is formed between the "zero-point" of the hairpin (the point where
> it
> > begins to open) and the ending point of the higher hairpin line, that is
> in
> > (width, height). The function takes into account that the lines of
> hairpins
> > that go through a system break have different starting and ending
> heights,
> > this is called "adjusted height" here.
>
> But the spanner is cloned for each broken segment, so you aren't
> actually comparing
> with the initial bit.  Each new segment is simply drawn with a stencil
> reflecting its
> position within the whole.
>
> With all this in mind, the function
> > finds the angle of the upper line of the hairpin, and returns the
> negative
> > of that angle, which ideally would result in that angle being 0 degrees,
> > making it so that the upper line is parallel to the staff. But the end
> > result is slightly off (see image). I don't know if the math is wrong or
> if
> > this problem arises from rounding differences. If it is the later I may
> need
> > to formulate another approach entirely. Any insight on this?
>
> I noticed this.  I'm not great with trig, so I'm not seeing right away
> how to approach this
> by rotating the hairpin.  But why rotate it in the first place?  You
> simply want the top or
> bottom line--you also need to consider if the hairpin is above the
> staff--to be horizontal.  So
> create a property 'follow-staff or something and, when set, draw a
> straight line for one of the two lines
> which are joined to create the hairpin, instead of two lines which
> split the opening width.
>
> >
> > Thank you for all the help!!
>
> You're very welcome!
>
> David
>

Attachment: rotated hairpins.ly
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]