* scm/ps.scm (zigzag-line): added.
* ps/music-drawing-routines.ps (subvec): added.
(draw_zigzag_line): added.
* lily/line-spanner.cc: Add support for #'type = #'zigzag. reading
grob properties zigzag-width and zigzag-length.
* input/regression/glissando.ly: Add some zig-zagged glissandi.
+2002-10-15 Rune Zedeler <rune@zedeler.dk>
+
+ * scm/tex.scm (zigzig-line): added.
+
+ * scm/ps.scm (zigzag-line): added.
+
+ * ps/music-drawing-routines.ps (subvec): added.
+ (draw_zigzag_line): added.
+
+ * lily/line-spanner.cc: Add support for #'type = #'zigzag. reading
+ grob properties zigzag-width and zigzag-length.
+
+ * input/regression/glissando.ly: Add some zig-zagged glissandi.
+
2002-10-15 Jan Nieuwenhuizen <janneke@gnu.org>
* scm/sodipodi.scm: Some fixes. Sketch also groks this bare-bones
% gliss non gliss and
c4 \glissando d e \glissando f \glissando \break
% consecutive
- c \glissando d \glissando e
+ c \glissando d, \glissando e'
< { \stemUp e8 \glissando g8 }
\context Voice = VB {\stemDown \repeat unfold 4 d16 } >
-
+ \property Voice.Glissando \override #'type = #'zigzag
+ c4 \glissando c,, \glissando c' \glissando d
}
\paper{
- linewidth = 70.\mm
+ linewidth = 50.\mm indent = 0
\translator{
\StaffContext
% makes for handier debugging
return list;
}
+static SCM
+zigzag_atom (Grob* me, Real thick, Real dx, Real dy)
+{
+ Real staff_space = Staff_symbol_referencer::staff_space (me);
+ SCM ws = me->get_grob_property ("zigzag-width");
+ SCM ls = me->get_grob_property ("zigzag-length");
+ double w = (gh_number_p(ws) ? gh_scm2double(ws) : 1)*staff_space;
+ double l = (gh_number_p(ls) ? gh_scm2double(ls) : 1)*w;
+ double h = l>w/2 ? sqrt(l*l-w*w/4) : 0;
+
+ SCM list = scm_list_n (ly_symbol2scm ("zigzag-line"),
+ gh_bool2scm (true),
+ gh_double2scm (w),
+ gh_double2scm (h),
+ gh_double2scm (thick),
+ gh_double2scm (dx),
+ gh_double2scm (dy),
+ SCM_UNDEFINED);
+
+ return list;
+}
+
+
+
Molecule
Line_spanner::line_molecule (Grob* me, Real thick, Real dx, Real dy)
{
Interval (- 0.5* thick + (0<? dy), 0.5*thick + (0 >? dy)));
mol = Molecule (b, line_atom (me, thick, dx, dy));
}
+ else if (gh_symbol_p (type)
+ && type == ly_symbol2scm ("zigzag"))
+ {
+ // TODO:
+ Box b (Interval (-0.5* thick + (0 <? dx) ,0.5* thick+ (0 >? dx)),
+ Interval (- 0.5* thick + (0<? dy), 0.5*thick + (0 >? dy)));
+ mol = Molecule (b, zigzag_atom (me, thick, dx, dy));
+
+ }
else if (gh_symbol_p (type)
&& type == ly_symbol2scm ("trill"))
{
ADD_INTERFACE (Line_spanner, "line-spanner-interface",
"Generic line drawn between two objects, eg. for use with glissandi.
gap is measured in staff-spaces. ",
- "gap dash-period dash-length thickness type");
+ "gap dash-period dash-length zigzag-width zigzag-length thickness type");
} bind def
+% a b c d subvec == a-c b-d
+/subvec {
+ 3 2 roll exch sub
+ 3 1 roll
+ sub exch
+} bind def
+
+
+% centre? zzwidth zzheight thickness x0 y0 x1 y1
+/draw_zigzag_line {
+ newpath
+ 6 dict begin
+
+ 4 2 roll % zzuw zzh th x1 y1 x0 y0
+ 2 copy
+ moveto
+ subvec % zzuw zzh th dx dy
+
+ 2 copy euclidean_length /l exch def
+ l div /uy exch def
+ l div /ux exch def
+ setlinewidth
+ /zzh exch def
+ l exch div round /n exch def
+ n 0 gt { %if
+ /zzw l n 2 mul div def
+ {
+ uy zzh mul 2 div ux zzh mul -2 div rmoveto
+ } if
+ 1 1 n {
+ ux zzw mul uy zzh mul sub
+ uy zzw mul ux zzh mul add
+ rlineto
+ ux zzw mul uy zzh mul add
+ uy zzw mul ux zzh mul sub
+ rlineto
+ } bind for
+ }{ %else
+ pop
+ ux l mul uy l mul rlineto
+ } ifelse
+ stroke
+ end
+} bind def
/bracket_traject
{
. (
(type . line)
(gap . 0.5)
+ (zigzag-width . 0.75)
(breakable . #t)
(X-extent-callback . #f)
(Y-extent-callback . #f)
(grob-property-description 'tie ly:grob? "")
(grob-property-description 'type symbol? "
-one of: line, dashed-line, trill or dotted-line.
+one of: line, dashed-line, trill, dotted-line or zigzag.
-[FIXME: type is too generic for this doc, move doco to intefrace]
+[FIXME: type is too generic for this doc, move doco to interface]
")
(grob-property-description 'break-visibility procedure? "a function that takes the break direction and returns a cons of booleans containing (TRANSPARENT . EMPTY).
(grob-property-description 'width-correct number? "width correction for (de)cresc. text spanners.")
(grob-property-description 'x-gap number? "horizontal gap between notehead and tie.")
(grob-property-description 'y-free number? "minimal vertical gap between slur and noteheads or stems.")
-(grob-property-description 'y-offset number? "extra vertical offset for ties away from the center line.")
+(grob-property-description 'y-offset number? "extra vertical offset
+for ties away from the center line.")
+(grob-property-description 'zigzag-length number? "The length of the
+lines of a zigzag - relative to zigzag-width. a value of 1
+gives 60-degree zigzags.")
+(grob-property-description 'zigzag-width number? "the width of one
+zigzag-squiggle, measured in staff space. The width will be adjusted
+so that the line can be constructed from a whole number of squiggles.")
;;; INTERNAL
(numbers->string
(list x y radius)) " draw_dot"))
+(define (zigzag-line centre? zzw zzh thick dx dy)
+ (string-append
+ (if centre? "true" "false")
+ " "
+ (ly:number->string zzw)
+ " "
+ (ly:number->string zzh)
+ " "
+ (ly:number->string thick)
+ " 0 0 "
+ (ly:number->string dx)
+ " "
+ (ly:number->string dy)
+ " draw_zigzag_line "))
+
(define (draw-line thick x1 y1 x2 y2)
(string-append
" 1 setlinecap
(define (dashed-line thick on off dx dy)
(embedded-ps (list 'dashed-line thick on off dx dy)))
+(define (zigzag-line centre? zzw zzh thick dx dy)
+ (embedded-ps (list 'zigzag-line centre? zzw zzh thick dx dy)))
+
(define (font-load-command name-mag command)
(string-append
"\\font\\" command "="