lilypond-devel
[Top][All Lists]
Advanced

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

New notehead (accent)


From: Maximilian Albert
Subject: New notehead (accent)
Date: Mon, 02 Apr 2007 10:45:42 +0200
User-agent: IceDove 1.5.0.10 (X11/20070307)

Hi everybody,

here is a patch for a new accent-shaped notehead, as requested by Jamie
and Trevor on this list a while ago. An example of what it looks like is
attached. Would it be possibe to include this in the next development
release? The second patch is to update the docs.

Thanks,
Max

>From b2f1b6e0afb63329555a6632f413f05cfe6c08e6 Mon Sep 17 00:00:00 2001
From: Maximilian Albert <address@hidden>
Date: Sun, 1 Apr 2007 00:21:20 +0200
Subject: [PATCH] New accent-shaped notehead

---
 lily/include/note-head.hh |    1 +
 lily/note-head.cc         |   28 +++++++++++++
 mf/feta-bolletjes.mf      |   97 +++++++++++++++++++++++++++++++++++++++++++++
 scm/define-grobs.scm      |    2 +-
 scm/output-lib.scm        |    1 +
 5 files changed, 128 insertions(+), 1 deletions(-)

diff --git a/lily/include/note-head.hh b/lily/include/note-head.hh
index 0891b7d..8d39a2d 100644
--- a/lily/include/note-head.hh
+++ b/lily/include/note-head.hh
@@ -24,6 +24,7 @@ public:
   DECLARE_SCHEME_CALLBACK (brew_ez_stencil, (SCM));
   DECLARE_SCHEME_CALLBACK (stem_x_shift, (SCM));
   DECLARE_SCHEME_CALLBACK (calc_stem_attachment, (SCM));
+  DECLARE_SCHEME_CALLBACK (y_offset_callback, (SCM));
   DECLARE_GROB_INTERFACE();
   static Real stem_attachment_coordinate (Grob *, Axis a);
   static int get_balltype (Grob *);
diff --git a/lily/note-head.cc b/lily/note-head.cc
index c711f87..18d051e 100644
--- a/lily/note-head.cc
+++ b/lily/note-head.cc
@@ -15,6 +15,7 @@
 using namespace std;
 
 #include "directional-element-interface.hh"
+#include "staff-symbol-referencer.hh"
 #include "font-interface.hh"
 #include "international.hh"
 #include "warn.hh"
@@ -141,6 +142,33 @@ Note_head::calc_stem_attachment (SCM smob)
   return ly_offset2scm (get_stem_attachment (fm, key));
 }
 
+MAKE_SCHEME_CALLBACK (Note_head, y_offset_callback, 1);
+SCM
+Note_head::y_offset_callback (SCM smob)
+{
+  Grob *me = unsmob_grob (smob);
+  SCM style_scm = me->get_property ("style");
+  double offset = scm_to_double (Staff_symbol_referencer::callback (smob));
+
+  if (!scm_is_symbol (style_scm))
+    return scm_from_double (offset);
+
+  string style = string (ly_symbol2string (style_scm));
+  if (style != "accent")
+    return scm_from_double (offset);
+
+  double extra_offset;
+  if (scm_to_int (me->get_property ("staff-position")) % 2 == 0) {
+    Real linethickness = Staff_symbol_referencer::line_thickness (me);
+    // The precise value of the following factor depends on the parameters in 
mf/feta-bolletjes.mf
+    extra_offset = - 127.0/60 * linethickness; 
+
+  } else {
+    extra_offset = 0.0;
+  }
+
+  return scm_from_double (offset + extra_offset);
+}
 
 ADD_INTERFACE (Note_head,
               "Note head",
diff --git a/mf/feta-bolletjes.mf b/mf/feta-bolletjes.mf
index 36abfcf..9652d3b 100644
--- a/mf/feta-bolletjes.mf
+++ b/mf/feta-bolletjes.mf
@@ -970,6 +970,103 @@ fi;
 
 %%%%%%%%
 %
+% Accent-shaped notehead
+%
+
+def draw_accent_notehead (expr width_factor, clearing_factor, ratio, upper_th, 
thick_factor, upstem) =
+begingroup;
+        save upper_thickness, lower_thickness, clearing;
+        save ww, hh;
+        save roundness;
+        save se, ne, up_dist, down_dist;
+        pair se, ne, up_dist, down_dist;
+  
+        hh# := staff_space# + stafflinethickness# * upper_th;
+        ww# := hh# * width_factor;
+        set_char_box (0, ww#, hh#, 0);
+        define_pixels (ww, hh);
+
+        upper_thickness = stafflinethickness * upper_th;
+        lower_thickness = stafflinethickness * upper_th * thick_factor;
+        clearing = stafflinethickness * clearing_factor;
+        roundness = stafflinethickness * 0.5;
+
+  
+        pickup pencircle scaled roundness;
+    
+        lft x1 = lft x3 = lft x4 = lft x6 = 0;
+        rt x2 = ww;
+        bot y1 = 0;
+        top y6 - bot y1 = lower_thickness;
+        top y3 - bot y4 = upper_thickness;
+        y2 - bot y1 = ratio * (top y3 - bot y1);
+  
+        bot y4 - clearing =  staff_space;
+
+        z5 - z4 = whatever * (z2 - z3);
+        z5 - z6 = whatever * (z2 - z1);
+  
+        se = unitvector (z2 - z3);
+        ne = unitvector (z2 - z1);
+
+        up_dist = (se rotated 90) * 0.5 roundness;
+        down_dist = (ne rotated (-90)) * 0.5 roundness;
+
+        z5a = whatever[z4 - up_dist, z5 - up_dist] = whatever[z6 - down_dist, 
z5 - down_dist];
+
+        fill lft z1{down}
+             .. (z1 + down_dist){ne}
+             -- (z2 + down_dist){ne}
+             .. (z2 + up_dist){-se}
+             -- (z3 + up_dist){-se}
+             .. lft z3{down}
+             -- lft z4{down}
+             .. (z4 - up_dist){se}
+             -- z5a
+             -- (z6 - down_dist){-ne}
+             .. lft z6{down}
+             --cycle;
+
+
+        % stem attachment adjustments
+        if upstem:
+               z7  = 0.5[z2,z3];
+                z7a = whatever[z4,z5];
+                z7a = (x7 - stemthickness/2, whatever);
+                z7b = z7a shifted (stemthickness,0); 
+                % the shift in the following line is to account for the 
assignment to currentpicture below
+                z8 = z7b shifted (0, -(staff_space - stafflinethickness)/2);
+        else:
+                z7  = 0.5[z2,z1];
+                z7a = whatever[z6,z5];
+                z7a = (x7 - stemthickness/2, whatever);
+                % the shift in the following line is to account for the 
assignment to currentpicture below
+                z8 = (ww,0) - (z7a shifted (0, -(staff_space - 
stafflinethickness)/2));
+        fi;
+        currentpicture := currentpicture shifted (0, -(staff_space - 
stafflinethickness)/2);
+        charwx := x8/hppp;
+        charwy := y8/hppp;
+
+        labels(range 1 thru 8, 5a, 7a, 7b);
+endgroup;
+enddef;
+
+
+% N.B.: When changing the parameters in the following function calls,
+% please adapt the factor in Note_head::y_offset_callback accordingly
+% so that accents are centered on stafflines.
+
+fet_beginchar("Accent-shaped notehead", "u0accent");
+        draw_accent_notehead(1.0, 0.4, 0.5, 1.7, 5/3, true);
+fet_endchar;
+
+fet_beginchar("Accent-shaped notehead", "d0accent");
+        draw_accent_notehead(1.0, 0.4, 0.5, 1.7, 5/3, false);
+fet_endchar;
+
+
+%%%%%%%%
+%
 % SOLFA SHAPED NOTES
 %
 
diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm
index 85d48b1..2be910b 100644
--- a/scm/define-grobs.scm
+++ b/scm/define-grobs.scm
@@ -1145,7 +1145,7 @@
        (duration-log . ,note-head::calc-duration-log)
        (stem-attachment . ,ly:note-head::calc-stem-attachment)
        (glyph-name . ,note-head::calc-glyph-name) 
-       (Y-offset . ,ly:staff-symbol-referencer::callback)
+       (Y-offset . ,ly:note-head::y-offset-callback)
        (X-offset . ,ly:note-head::stem-x-shift)
        (meta . ((class . Item)
                 (interfaces . (rhythmic-grob-interface
diff --git a/scm/output-lib.scm b/scm/output-lib.scm
index 3cfefc8..0023e34 100644
--- a/scm/output-lib.scm
+++ b/scm/output-lib.scm
@@ -154,6 +154,7 @@
       ;; Therefore, style "default" does not appear in this case
       ;; statement.  -- jr
       ((xcircle) "2xcircle")
+      ((accent) "0accent")
       ((harmonic) "0harmonic")
       ((harmonic-black) "2harmonic")
       ((harmonic-mixed) (if (<= log 1) "0harmonic"
-- 
1.4.4.4


>From e46e423bf3fbc2107d4e5a69dbdee87fb6e4cb83 Mon Sep 17 00:00:00 2001
From: Maximilian Albert <address@hidden>
Date: Sun, 1 Apr 2007 00:47:43 +0200
Subject: [PATCH] Add new accent-shaped notehead to docs

---
 input/manual/note-head-style.ly     |    4 ++++
 input/regression/note-head-style.ly |    4 ++++
 2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/input/manual/note-head-style.ly b/input/manual/note-head-style.ly
index c561eec..0759927 100644
--- a/input/manual/note-head-style.ly
+++ b/input/manual/note-head-style.ly
@@ -91,6 +91,10 @@ pattern = <<
 
   \break
 
+  \override Staff.NoteHead  #'style = #'accent
+  s1*0^\markup { "accent" }
+  \pattern
+
   \override Staff.NoteHead  #'style = #'slash
   s1*0^\markup { "slash" }
   \pattern
diff --git a/input/regression/note-head-style.ly 
b/input/regression/note-head-style.ly
index c561eec..0759927 100644
--- a/input/regression/note-head-style.ly
+++ b/input/regression/note-head-style.ly
@@ -91,6 +91,10 @@ pattern = <<
 
   \break
 
+  \override Staff.NoteHead  #'style = #'accent
+  s1*0^\markup { "accent" }
+  \pattern
+
   \override Staff.NoteHead  #'style = #'slash
   s1*0^\markup { "slash" }
   \pattern
-- 
1.4.4.4


Attachment: accent.pdf
Description: Adobe PDF document


reply via email to

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