2 easy-notation.cc -- implement easy notation heads
4 source file of the GNU LilyPond music typesetter
6 (c) 2005--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
9 #include "note-head.hh"
14 #include "text-interface.hh"
16 #include "output-def.hh"
19 #include "font-interface.hh"
20 #include "staff-symbol-referencer.hh"
28 MAKE_SCHEME_CALLBACK (Note_head, brew_ez_stencil, 1);
30 Note_head::brew_ez_stencil (SCM smob)
32 Grob *me = unsmob_grob (smob);
33 int log = Note_head::get_balltype (me);
35 SCM cause = me->get_property ("cause");
36 SCM spitch = unsmob_music (cause)->get_property ("pitch");
37 Pitch *pit = unsmob_pitch (spitch);
39 SCM idx = scm_from_int (pit->get_notename ());
40 SCM names = me->get_property ("note-names");
41 SCM charstr = SCM_EOL;
42 if (scm_is_vector (names))
43 charstr = scm_vector_ref (names, idx);
47 s[0] = (pit->get_notename () + 2) % 7 + 'a';
48 s[0] = toupper (s[0]);
49 charstr = scm_makfrom0str (s);
53 = Text_interface::interpret_string (me->layout ()->self_scm (),
54 Font_interface::text_font_alist_chain (me),
57 Stencil l (*unsmob_stencil (letter));
58 l.align_to (X_AXIS, CENTER);
59 l.align_to (Y_AXIS, CENTER);
61 l = Stencil (Box (), l.expr ());
62 Real ss = Staff_symbol_referencer::staff_space (me);
63 Real lt = Staff_symbol_referencer::line_thickness (me);
65 Real radius = (ss + lt) / 2.0;
66 Real stem_thick = 1.3 * lt;
67 if (Grob *stem = unsmob_grob (me->get_object ("stem")))
68 stem_thick = Stem::thickness (stem);
70 int black = (log >= 2);
73 Box extent (Interval (-radius, radius),
74 Interval (-radius, radius));
76 Stencil black_head (extent,
77 scm_list_4 (ly_symbol2scm ("circle"),
78 scm_from_double (radius),
79 scm_from_double (0.0),
83 l = l.in_color (1, 1, 1);
86 white_head = Stencil (extent,
87 scm_list_4 (ly_symbol2scm ("circle"),
88 scm_from_double (radius - stem_thick),
89 scm_from_double (0.0),
92 white_head = white_head.in_color (1, 1, 1);
96 total.add_stencil (l);
97 total.add_stencil (white_head);
98 total.add_stencil (black_head);
99 total.translate_axis (radius, X_AXIS);
101 return total.smobbed_copy ();