Re: Flat slurs

2017-02-14 Thread Urs Liska
Hi Abraham,


Am 13.02.2017 um 23:49 schrieb Abraham Lee:
> On Mon, Feb 13, 2017 at 1:16 PM, Urs Liska <u...@openlilylib.org
> <mailto:u...@openlilylib.org>> wrote:
>
> Yes, I'd definitely like to see that. How did you manage to get
> the seamless "thick" line?
>
>
> Ok. You asked for it... ;-)
>
> I did it by completely redefining the stencil completely using a
> markup path. The path has a line thickness and a shape thickness,
> similar to how slurs are created. See below for full code and examples
> (works with 2.18.2 and newer, from my tests).

Thanks for this. I hope to find the time to inspect it more closely.
Interestingly (and unfortunately) there seems to be more or less nothing
in it that I could simply take over since you followed a completely
different approach. But there are interesting ways to interact with the
internals that I will want to study to enhance my repertoire.

As said, "my" version is a special case for multi-segment slurs, and the
approach to get robust flat slurs/ties would rather be writing wrapper
functions for these.

As a suggestion I wrote an alternative wrapper function (very basic
initial version) that you may or may not find interesting:

%

flattenedSlur =
#(define-music-function (mod)(ly:context-mod?)
   (let*
((props (map (lambda (m)
   (cons (second m) (third m)))
  (ly:get-context-mods mod)))
 (start-y (assq-ref props 'start-y))
 (left-height (assq-ref props 'left-height))
 (left-width (assq-ref props 'left-height))
 (right-width (assq-ref props 'right-width))
 (right-height (assq-ref props 'right-height))
 )
#{
  \once \override Slur.stencil =
  #(flattened-slur
start-y left-height left-width right-width right-height)
#}
))

%%

which can be used as


\flattenedSlur \with {
  start-y = 0
  left-height = 2
  left-width = 4
  right-width = 6
  right-height = 3.5
}


Initially this seems much more to type, but on the other hand it's much
easier to read. And most importantly you can incorporate defaults (e.g.
mirroring the height and width arguments if only one is given, or you
could add the 'ratio to optionally override its value).
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Flat slurs

2017-02-13 Thread Abraham Lee
On Mon, Feb 13, 2017 at 1:16 PM, Urs Liska  wrote:
>
> Yes, I'd definitely like to see that. How did you manage to get the
> seamless "thick" line?
>

Ok. You asked for it... ;-)

I did it by completely redefining the stencil completely using a markup
path. The path has a line thickness and a shape thickness, similar to how
slurs are created. See below for full code and examples (works with 2.18.2
and newer, from my tests).

%<-

\version "2.18.2"

#(define (general-flattened-curve points thickness line-thickness ratio)
  "The four points passed to this function are as follows:
   - p0: left-most real control point location (x,y)
   - p1: left-curve-width, left-curve-rise
   - p2: right-curve-width, right-curve-rise
   - p3: right-most real control point location (x,y)

   For Ties, p1 rise and p2 rise should be the same, as should p0y and p3y"
  (let* ((p0 (car points))
 (p1 (cadr points))
 (p2 (caddr points))
 (p3 (cadddr points))
 (halfthick (/ thickness 2))

 (p00x (car p0))
 (p33x (car p3))
 (p11x (+ p00x (car p1)))
 (p22x (- p33x (car p2)))
 (p10x (+ p00x (* (- p11x p00x) (expt (- 1 ratio) 2
 (p01x (+ p00x (* (- p10x p00x) ratio)))
 (p23x (- p33x (* (- p33x p22x) (expt (- 1 ratio) 2
 (p32x (+ p23x (* (- p33x p23x) (- 1 ratio
 (p34x p32x)
 (p43x p23x)
 (p44x p22x)
 (p55x p11x)
 (p50x p10x)
 (p05x p01x)

 (p00y (cdr p0))
 (p11y (- (cdr p1) halfthick))
 (p22y (- (cdr p2) halfthick))
 (p33y (cdr p3))
 (p10y p11y)
 (p23y p11y)
 (p01y (+ p00y (* (- p11y p00y) ratio)))
 (p32y (+ p33y (* (- p22y p33y) ratio)))
 (p44y (+ p22y thickness))
 (p55y (+ p11y thickness))
 (p43y p44y)
 (p34y (+ p33y (* (- p44y p33y) ratio)))
 (p05y (+ p00y (* (- p55y p00y) ratio)))
 (p50y p55y)
)
(markup
  (#:override (cons 'filled #t)
(#:path line-thickness
  (list (list 'moveto p00x p00y)
(list 'curveto p01x p01y p10x p10y p11x p11y)
(list 'lineto p22x p22y)
(list 'curveto p23x p23y p32x p32y p33x p33y)
(list 'curveto p34x p34y p43x p43y p44x p44y)
(list 'lineto p55x p55y)
(list 'curveto p50x p50y p05x p05y p00x p00y)
(list 'closepath)
  )
)
  )
)
  )
)

#(define ((flattened-slur start-y left-height left-width right-width
right-height) grob)
  ;; outer let to trigger suicide
  (let ((stil (ly:slur::print grob)))
(if (grob::is-live? grob)
(let* ((layout (ly:grob-layout grob))
   (optical-thinner 0.8)
   (def-line-thickness (ly:output-def-lookup layout
'line-thickness))
   (line-thickness
 (* def-line-thickness (ly:grob-property grob
'line-thickness 0.8)))
   (thickness
 (* optical-thinner
   (* def-line-thickness (ly:grob-property grob 'thickness
1.2
   (ratio (ly:grob-property grob 'ratio))
   (dir (ly:grob-property grob 'direction))
   (xex (ly:stencil-extent stil X))
   (yex (ly:stencil-extent stil Y))
   (lenx (interval-length xex))
   (leny (interval-length yex))
   (lenratio (/ left-width (+ left-width right-width)))
   (1-lenratio (1- lenratio))
   (left-tip-width (min left-width (* lenx lenratio)))
   (right-tip-width (min right-width (* lenx (- 1 lenratio
   (left-tip-height (+ start-y left-height))
   (right-tip-height (- left-tip-height right-height))
   (xtrans (car xex))
   (ytrans (if (> dir 0)(car yex) (cdr yex)))
   (cpts (list
 (cons 0 (* dir start-y))
 (cons left-tip-width (* dir left-tip-height))
 (cons right-tip-width (* dir left-tip-height))
 (cons lenx (* dir right-tip-height
   (newstil
 (grob-interpret-markup grob
   (general-flattened-curve cpts thickness line-thickness
ratio)))
  )
  (ly:stencil-translate newstil (cons xtrans ytrans)))
stil)))

#(define ((flattened-tie tip-width height) grob)
  ;; outer let to trigger suicide
  (let ((stil (ly:tie::print grob)))
(if (grob::is-live? grob)
(let* ((layout (ly:grob-layout grob))
   (optical-thinner 0.8)
   (def-line-thickness (ly:output-def-lookup layout
'line-thickness))
   (line-thickness
 (* def-line-thickness (ly:grob-property grob
'line-thickness 0.8)))
   (thickness
 (* optical-thinner
   (* def-line-thickness 

Re: Flat slurs

2017-02-13 Thread Urs Liska


Am 13.02.2017 um 18:30 schrieb Abraham Lee:
> On Mon, Feb 13, 2017 at 8:50 AM, tisimst <tisimst.lilyp...@gmail.com
> <mailto:tisimst.lilyp...@gmail.com>> wrote:
>
> Urs, et al,
>
> On Mon, Feb 13, 2017 at 8:22 AM, Kieren MacMillan-2 [via Lilypond]
> <[hidden email]
> <http:///user/SendEmail.jtp?type=node=200071=0>> wrote:
>
> Hi Urs,
>
> > This is a more real-world (but not too fine-tuned) example
> where it's
> > clear that flat slurs can save lots of vertical space.
>
> Lovely work! Thank you for your ongoing efforts in this area.
>
>
> Agreed. This is great. I also cobbled together my own Scheme code
> a while back for doing flat ties/slurs, but my flat slurs are far
> from automagic.
>

"My" slurs aren't automatic either. In fact they are special cases of
multi-segment slurs which of course have to be defined manually
(although the interface for this is pretty robust).

> This should be ok since they aren't the most commonly used slur
> shape, but it makes me curious, Urs, what it takes to designate
> the proper shape in your code?
>

Basically you define right and left anchor points, an angle and a ratio
(ratio is the relative distance between the outer control points as
compared to the distance of the end points), then you can add an
arbitrary number of inflection points with a few properties each. The
syntax is a \with {} clause where each inflection is added as an alist
property.
A flat slur is a slur with two inflection points where the second one is
defined to have an angle of 0, which means that the left hand control
point points directly to the previous inflection.
You can see the code here:
https://github.com/openlilylib/snippets/blob/master/notation-snippets/shaping-bezier-curves/flat-compound-slur-example.ly



> I am happy to share my code if anyone is interested.
>

Yes, I'd definitely like to see that. How did you manage to get the
seamless "thick" line?

> I created it at the request of Dimitris Marinakis, so he may have
>     some real-world examples of how he used it.
>
> @Urs: One thing I've learned while doing all my typography work is
> that the flat slurs will look too thick if they use the same
> thickness value as normal slurs. This is because curved shapes
> look thinner than flat shapes and a normal slur only achieves its
> 'thickness at its mid-way point and nowhere else. It's an optical
> illusion, but one the eye definitely notices. In my code I use a
> simple thinning scale factor and it seems to do the trick.
>

It should be fairly simple to include that - if I write a wrapper
function for "flat ties/slurs". As said ATM this is a special case of a
multi-segment slur, so the user would simply have to change thickness
themselves.

>
> Here are a couple of examples of using flat ties and flat slurs and
> how they can be configured. They utilize Slur grob properties as much
> as possible, so properties such as 'thickness and 'ratio are used in
> my functions.

'ratio is something I indeed wanted to add.
Nice exmaples

Best
Urs

>
> Best,
> Abraham 
>
>
> ___
> lilypond-user mailing list
> lilypond-user@gnu.org
> https://lists.gnu.org/mailman/listinfo/lilypond-user

-- 
u...@openlilylib.org
https://openlilylib.org
http://lilypondblog.org

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Flat slurs

2017-02-13 Thread Urs Liska


Am 13.02.2017 um 15:51 schrieb David Kastrup:
>> This is a more real-world (but not too fine-tuned) example where it's
>> clear that flat slurs can save lots of vertical space.
> Butt-ugly.  There really is no need to almost touch the first and last
> note when the slur passes other notes with lots more clearance anyway.
>
> This example would really better be done by much less overall curveage.

As hinted I didn't bother beautifying this very much. In particular I
didn't bother changing the anchor points from what Lily decided for the
regular slur.

The examples from Durand and Henle
https://cloud.ursliska.de/index.php/s/r9Qhl6xzEkgQdSG
https://cloud.ursliska.de/index.php/s/4Yo75DclklXWaC8
show the use case for flat slurs better.

Henle (done with Finale) doesn't have flat slurs so the staves are
unnecessarily pushed apart

-- 
u...@openlilylib.org
https://openlilylib.org
http://lilypondblog.org

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Flat slurs

2017-02-13 Thread Abraham Lee
On Mon, Feb 13, 2017 at 8:50 AM, tisimst <tisimst.lilyp...@gmail.com> wrote:

> Urs, et al,
>
> On Mon, Feb 13, 2017 at 8:22 AM, Kieren MacMillan-2 [via Lilypond] <[hidden
> email] <http:///user/SendEmail.jtp?type=node=200071=0>> wrote:
>
>> Hi Urs,
>>
>> > This is a more real-world (but not too fine-tuned) example where it's
>> > clear that flat slurs can save lots of vertical space.
>>
>> Lovely work! Thank you for your ongoing efforts in this area.
>>
>
> Agreed. This is great. I also cobbled together my own Scheme code a while
> back for doing flat ties/slurs, but my flat slurs are far from automagic.
> This should be ok since they aren't the most commonly used slur shape, but
> it makes me curious, Urs, what it takes to designate the proper shape in
> your code? I am happy to share my code if anyone is interested. I created
> it at the request of Dimitris Marinakis, so he may have some real-world
> examples of how he used it.
>
> @Urs: One thing I've learned while doing all my typography work is that
> the flat slurs will look too thick if they use the same thickness value as
> normal slurs. This is because curved shapes look thinner than flat shapes
> and a normal slur only achieves its 'thickness at its mid-way point and
> nowhere else. It's an optical illusion, but one the eye definitely notices.
> In my code I use a simple thinning scale factor and it seems to do the
> trick.
>

Here are a couple of examples of using flat ties and flat slurs and how
they can be configured. They utilize Slur grob properties as much as
possible, so properties such as 'thickness and 'ratio are used in my
functions.

Best,
Abraham


flat-ties.pdf
Description: Adobe PDF document


flat-slurs.pdf
Description: Adobe PDF document
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Flat slurs

2017-02-13 Thread tisimst
Urs, et al,

On Mon, Feb 13, 2017 at 8:22 AM, Kieren MacMillan-2 [via Lilypond] <
ml-node+s1069038n200067...@n5.nabble.com> wrote:

> Hi Urs,
>
> > This is a more real-world (but not too fine-tuned) example where it's
> > clear that flat slurs can save lots of vertical space.
>
> Lovely work! Thank you for your ongoing efforts in this area.
>

Agreed. This is great. I also cobbled together my own Scheme code a while
back for doing flat ties/slurs, but my flat slurs are far from automagic.
This should be ok since they aren't the most commonly used slur shape, but
it makes me curious, Urs, what it takes to designate the proper shape in
your code? I am happy to share my code if anyone is interested. I created
it at the request of Dimitris Marinakis, so he may have some real-world
examples of how he used it.

@Urs: One thing I've learned while doing all my typography work is that the
flat slurs will look too thick if they use the same thickness value as
normal slurs. This is because curved shapes look thinner than flat shapes
and a normal slur only achieves its 'thickness at its mid-way point and
nowhere else. It's an optical illusion, but one the eye definitely notices.
In my code I use a simple thinning scale factor and it seems to do the
trick.

Best,
Abraham




--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/Flat-slurs-tp200061p200071.html
Sent from the User mailing list archive at Nabble.com.___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Flat slurs

2017-02-13 Thread Kieren MacMillan
Hi Urs,

> This is a more real-world (but not too fine-tuned) example where it's
> clear that flat slurs can save lots of vertical space.

Lovely work! Thank you for your ongoing efforts in this area.

Best,
Kieren.


Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info
‣ email: i...@kierenmacmillan.info


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Flat slurs

2017-02-13 Thread David Kastrup
Urs Liska <u...@openlilylib.org> writes:

> Am 13.02.2017 um 12:25 schrieb Urs Liska:
>> Hi all,
>>
>> today I stumbled over some code in LilyPond's code base that creates a
>> bezier sandwich in Scheme. From this I was able to create a function
>> that creates opening and closing half sandwiches and connect them with
>> straight line beziers.
>>
>> With this function (in notation-snippets/shaping-bezier-curves in
>> https://github.com/openlilylib/snippets) it is now possible to draw real
>> flat slurs (see attachment). When I initially worked on multi-segment
>> slurs they suffered from being thinned out at each inflection point.
>>
>> There will be some room for improvements and syntactic sugar (e.g. to
>> simplify flat slurs or easily produce symmetric ones), but I'm already
>> extremely happy with this?
>>
>> Best
>> Urs
>
> This is a more real-world (but not too fine-tuned) example where it's
> clear that flat slurs can save lots of vertical space.

Butt-ugly.  There really is no need to almost touch the first and last
note when the slur passes other notes with lots more clearance anyway.

This example would really better be done by much less overall curveage.

-- 
David Kastrup

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Flat slurs

2017-02-13 Thread Urs Liska


Am 13.02.2017 um 15:00 schrieb Urs Liska:
> Am 13.02.2017 um 12:25 schrieb Urs Liska:
>> Hi all,
>>
>> today I stumbled over some code in LilyPond's code base that creates a
>> bezier sandwich in Scheme. From this I was able to create a function
>> that creates opening and closing half sandwiches and connect them with
>> straight line beziers.
>>
>> With this function (in notation-snippets/shaping-bezier-curves in
>> https://github.com/openlilylib/snippets) it is now possible to draw real
>> flat slurs (see attachment). When I initially worked on multi-segment
>> slurs they suffered from being thinned out at each inflection point.
>>
>> There will be some room for improvements and syntactic sugar (e.g. to
>> simplify flat slurs or easily produce symmetric ones), but I'm already
>> extremely happy with this?
>>
>> Best
>> Urs
> This is a more real-world (but not too fine-tuned) example where it's
> clear that flat slurs can save lots of vertical space.

And a last one for today, fixing the poor drawing of the half-sandwich

-- 
u...@openlilylib.org
https://openlilylib.org
http://lilypondblog.org

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Flat slurs

2017-02-13 Thread Urs Liska

Am 13.02.2017 um 12:25 schrieb Urs Liska:
> Hi all,
>
> today I stumbled over some code in LilyPond's code base that creates a
> bezier sandwich in Scheme. From this I was able to create a function
> that creates opening and closing half sandwiches and connect them with
> straight line beziers.
>
> With this function (in notation-snippets/shaping-bezier-curves in
> https://github.com/openlilylib/snippets) it is now possible to draw real
> flat slurs (see attachment). When I initially worked on multi-segment
> slurs they suffered from being thinned out at each inflection point.
>
> There will be some room for improvements and syntactic sugar (e.g. to
> simplify flat slurs or easily produce symmetric ones), but I'm already
> extremely happy with this?
>
> Best
> Urs

This is a more real-world (but not too fine-tuned) example where it's
clear that flat slurs can save lots of vertical space.

-- 
u...@openlilylib.org
https://openlilylib.org
http://lilypondblog.org

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Flat slurs

2017-02-13 Thread Urs Liska
Hi all,

today I stumbled over some code in LilyPond's code base that creates a
bezier sandwich in Scheme. From this I was able to create a function
that creates opening and closing half sandwiches and connect them with
straight line beziers.

With this function (in notation-snippets/shaping-bezier-curves in
https://github.com/openlilylib/snippets) it is now possible to draw real
flat slurs (see attachment). When I initially worked on multi-segment
slurs they suffered from being thinned out at each inflection point.

There will be some room for improvements and syntactic sugar (e.g. to
simplify flat slurs or easily produce symmetric ones), but I'm already
extremely happy with this?

Best
Urs

-- 
u...@openlilylib.org
https://openlilylib.org
http://lilypondblog.org



flat-compound-slur-example.pdf
Description: Adobe PDF document
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user