]> git.donarmstrong.com Git - lilypond.git/blobdiff - ps/music-drawing-routines.ps
add TODO comment.
[lilypond.git] / ps / music-drawing-routines.ps
index 952cd490654394d822aca87f2bd9b55cc6484905..b665aff49a98416b292921c35f73a48ee74aec36 100644 (file)
@@ -2,22 +2,20 @@
 %
 % Functions for direct and embedded PostScript
 
-/blot-diameter { lilypondpaperblotdiameter } bind def
-
-% fucking redhat xdvi patch.
-/skeel { scale } bind def
 
+/blot-diameter { lilypondpaperblotdiameter } bind def
 
 /set_tex_dimen {
        cvr def     
 } bind def
 
+
+
 /euclidean_length  
 { 
        1 copy mul exch 1 copy mul add sqrt 
 } bind def 
 
-/skeel { scale } bind def
 % FIXME.  translate to middle of box.
 % Nice rectangle with rounded corners
 /draw_box % breapth width depth height
        } ifelse
 } bind def
 
+
+/draw_symmetric_x_triangle % h w th
+{
+    setlinewidth
+    0 0 moveto
+    dup 0 lineto
+    2 div 
+    exch lineto
+    0 0 lineto
+    stroke
+} bind def
+
 /draw_round_box % breapth width depth height blot
 {
        /blot exch def
        } ifelse
 } bind def 
 
+/draw_polygon % x(n) y(n) x(n-1) y(n-1) ... x(1) y(1) n blot
+{
+       /blot exch def
+
+       0 setlinecap
+       blot setlinewidth
+       1 setlinejoin
+
+       /points exch def
+       2 copy
+       moveto
+       1 1 points {pop lineto} for
+       currentdict /testing known {
+               %% outline only, for testing:
+               stroke
+       }{
+               closepath gsave stroke grestore fill
+       } ifelse
+} bind def
+
 /draw_repeat_slash % width slope thick
 {
        1 setlinecap
 
 % this is for drawing slurs. 
 /draw_bezier_sandwich  % thickness controls 
-{ 
+{
+    % round ending and round beginning
+    1 setlinejoin 1 setlinecap
        setlinewidth 
        moveto 
        curveto 
        lineto 
-       curveto 
+       curveto
+       closepath
        gsave 
        fill 
        grestore 
 } 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 
 {