Hi,

as brought up in http://lists.gnu.org/archive/html/lilypond-user/2018-09/msg00236.html broken hairpins look ugly when they are too short. This is (as pointed out by Harm) due to the fact that the heights at the broken edges are hardcoded in the C++ function printing the hairpin.

I suggest a two-fold remedy:

1) limit the heights at the broken edges so the height/width ratio of the sibling doesn't exceed a certain value (I'd start with 1/2)

2) make that ratio and the broken-heights values user-settable as grob properties.

I've given it a partial try that can be seen at https://github.com/lilypond/lilypond/pull/4. This commit (hopefully) implements part 1) of the above. I've also attached the patch. Since I don't have a working build environment right now I couldn't test this code, but it should be straightforward, I think.

I would be glad if someone could add the code to create the grob properties (should be little work but not if you have to first look everything up like me) in order to upload it for review later.

Urs

>From 500f284e6776eb90d389d378c0f92c7d02e5e9a0 Mon Sep 17 00:00:00 2001
From: Urs Liska <u...@openlilylib.org>
Date: Tue, 18 Sep 2018 11:53:23 +0200
Subject: [PATCH] Limit angle of broken hairpins

Broken parts of hairpins don't look good when they are too short.
This is because their height at the broken side is hard-coded to
2/3 and 1/3 of the hairpin's height. So when the sibling's width is small
the ratio/angle is too high to be visually pleasing.

This commit (initial thoughts) limits the width/height ratio of broken
hairpins to 1/2.

It would be good to provide both the broken-heights and the ratio
as native grob properties for Hairpin, though.
---
 lily/hairpin.cc | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/lily/hairpin.cc b/lily/hairpin.cc
index afd94f3ee0..5fe36a58ec 100644
--- a/lily/hairpin.cc
+++ b/lily/hairpin.cc
@@ -271,15 +271,18 @@ Hairpin::print (SCM smob)
 
   Real starth = 0;
   Real endh = 0;
+  Real max_ratio = width / 2
+  Real continued_height = height / 3
+  Real continuing_height = 2 * height / 3
   if (grow_dir < 0)
     {
-      starth = continuing ? 2 * height / 3 : height;
-      endh = continued ? height / 3 : 0.0;
+      starth = continuing ? std::min(continuing_height, max_ratio) : height;
+      endh = continued ? std::max(continued_height, height - max_ratio) : 0.0;
     }
   else
     {
-      starth = continued ? height / 3 : 0.0;
-      endh = continuing ? 2 * height / 3 : height;
+      starth = continued ? std::max(continued_height, height - max_ratio) : 0.0;
+      endh = continuing ? std::min(continuing_height, max_ratio) : height;
     }
 
   /*
-- 
2.18.0

_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel

Reply via email to