]> git.donarmstrong.com Git - lilypond.git/commitdiff
* scm/output-gnome.scm: remove beam routine.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 13 Jul 2005 14:13:23 +0000 (14:13 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 13 Jul 2005 14:13:23 +0000 (14:13 +0000)
* scm/output-ps.scm (scm): idem.

* scm/output-svg.scm: remove beam.

* ps/music-drawing-routines.ps: remove draw_beam.

* lily/lookup.cc (beam): use round_filled_polygon() for beam.

ChangeLog
lily/include/lookup.hh
lily/lookup.cc
ps/music-drawing-routines.ps
scm/define-music-properties.scm
scm/output-gnome.scm
scm/output-ps.scm
scm/output-socket.scm
scm/output-svg.scm
scm/output-tex.scm

index 03677cc680ac0d055d4ac48db22b4cb7d6defcc9..6254b6bf4e188747e79c29f2c0cab0f23aa96a55 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2005-07-13  Han-Wen Nienhuys  <hanwen@xs4all.nl>
+
+       * scm/output-gnome.scm: remove beam routine.
+
+       * scm/output-ps.scm (scm): idem.
+
+       * scm/output-svg.scm: remove beam.
+
+       * ps/music-drawing-routines.ps: remove draw_beam.
+
+       * lily/lookup.cc (beam): use round_filled_polygon() for beam.
+
+       * flower/include/guile-compatibility.hh (scm_from_locale_string):
+       add scm_from_locale_string compatibility glue. 
+
 2005-07-13  Yoshinobu Isizaki  <isizaki@mte.biglobe.ne.jp>
 
        * scripts/lilypond-book.py: Prevent occuring error when
index b4aab56817f67670471b91d0aac46af06cf494f2..2e22a507873c62cd5d55640088d6c62b6952d85d 100644 (file)
@@ -17,7 +17,7 @@ struct Lookup
   static Stencil dot (Offset p, Real radius);
   static Stencil bracket (Axis a, Interval iv, Real thick, Real protude, Real blot);
   static Stencil accordion (SCM arg, Real interline_f, Font_metric *fm);
-  static Stencil round_filled_polygon (Array<Offset> points, Real blotdiameter);
+  static Stencil round_filled_polygon (Array<Offset> const &points, Real blotdiameter);
   static Stencil frame (Box b, Real thick, Real blot);
   static Stencil slur (Bezier controls, Real cthick, Real thick);
   static Stencil bezier_sandwich (Bezier top_curve, Bezier bottom_curve);
index cab5cc84414f3739233378ef2821a08d16f610b8..10e8bb7d5bdee25022fb41ef5babc73fdca48ee1 100644 (file)
@@ -37,40 +37,57 @@ Lookup::dot (Offset p, Real radius)
   return Stencil (box, at);
 }
 
-/*
- * Horizontal Slope:
- *
- *            /|   ^
- *           / |   |
- *          /  |   | height
- *         /   |   |
- *        /    |   v
- *       |    /
- *       |   /
- * (0, 0)x  /slope = dy/dx
- *       | /
- *       |/
- *
- *       <----->
- *        width
- */
 Stencil
 Lookup::beam (Real slope, Real width, Real thick, Real blot)
 {
-  Real height = slope * width;
-  Real min_y = min (0., height) - thick / 2;
-  Real max_y = max (0., height) + thick / 2;
-
-  Box b (Interval (0, width),
-        Interval (min_y, max_y));
-
-  SCM at = scm_list_n (ly_symbol2scm ("beam"),
-                      scm_make_real (width),
-                      scm_make_real (slope),
-                      scm_make_real (thick),
-                      scm_make_real (blot),
-                      SCM_UNDEFINED);
-  return Stencil (b, at);
+  Box b;
+
+  Offset p;
+
+  p = Offset (0, thick/2);
+  b.add_point (p);
+  p += Offset (1,-1) * (blot/2);
+
+  SCM points = SCM_EOL;
+  
+  points = scm_cons (scm_from_double (p[X_AXIS]),
+                    scm_cons (scm_from_double (p[Y_AXIS]),
+                              points));
+  
+  
+  p = Offset (0, -thick/2);
+  b.add_point (p);
+  p += Offset (1,1) * (blot/2);
+
+  points = scm_cons (scm_from_double (p[X_AXIS]),
+                    scm_cons (scm_from_double (p[Y_AXIS]),
+                              points));
+  
+  
+  p = Offset (width, width * slope - thick/2);
+  b.add_point (p);
+  p += Offset (-1, 1) * (blot/2);
+
+  points = scm_cons (scm_from_double (p[X_AXIS]),
+                    scm_cons (scm_from_double (p[Y_AXIS]),
+                              points));
+  
+  
+  p = Offset (width, width * slope + thick/2);
+  b.add_point (p);
+  p += Offset (-1, -1) * (blot/2);
+
+  points = scm_cons (scm_from_double (p[X_AXIS]),
+                    scm_cons (scm_from_double (p[Y_AXIS]),
+                              points));
+  
+  SCM expr = scm_list_n (ly_symbol2scm ("polygon"),
+                        ly_quote_scm (points),
+                        scm_make_real (blot),
+                        SCM_BOOL_T,
+                        SCM_UNDEFINED);
+  
+  return Stencil (b, expr);
 }
 
 Stencil
@@ -218,24 +235,26 @@ Lookup::round_filled_box (Box b, Real blotdiameter)
  * shrinked polygon). --jr
  */
 Stencil
-Lookup::round_filled_polygon (Array<Offset> points, Real blotdiameter)
+Lookup::round_filled_polygon (Array<Offset> const &points,
+                             Real blotdiameter)
 {
   /* TODO: Maybe print a warning if one of the above limitations
      applies to the given polygon.  However, this is quite complicated
      to check. */
 
-  /* remove consecutive duplicate points */
   const Real epsilon = 0.01;
-  for (int i = 0; i < points.size ();)
+
+#ifndef NDEBUG
+  /* remove consecutive duplicate points */
+  for (int i = 0; i < points.size (); i++)
     {
       int next_i = (i + 1) % points.size ();
       Real d = (points[i] - points[next_i]).length ();
       if (d < epsilon)
-       points.del (next_i);
-      else
-       i++;
+       programming_error ("Polygon should not have duplicate points");
     }
-
+#endif
+  
   /* special cases: degenerated polygons */
   if (points.size () == 0)
     return Stencil ();
@@ -245,8 +264,8 @@ Lookup::round_filled_polygon (Array<Offset> points, Real blotdiameter)
     return Line_interface::make_line (blotdiameter, points[0], points[1]);
 
   /* shrink polygon in size by 0.5 * blotdiameter */
-  Array<Offset> shrinked_points;
-  shrinked_points.set_size (points.size ());
+  Array<Offset> shrunk_points;
+  shrunk_points.set_size (points.size ());
   bool ccw = 1; // true, if three adjacent points are counterclockwise ordered
   for (int i = 0; i < points.size (); i++)
     {
@@ -287,27 +306,27 @@ Lookup::round_filled_polygon (Array<Offset> points, Real blotdiameter)
        }
       else
        p13 = (0.5 * blotdiameter / d) * p13n;
-      shrinked_points[i1] = p1 + ((ccw) ? p13 : -p13);
+      shrunk_points[i1] = p1 + ((ccw) ? p13 : -p13);
     }
 
   /* build scm expression and bounding box */
-  SCM shrinked_points_scm = SCM_EOL;
+  SCM shrunk_points_scm = SCM_EOL;
   Box box;
-  for (int i = 0; i < shrinked_points.size (); i++)
+  for (int i = 0; i < shrunk_points.size (); i++)
     {
-      SCM x = scm_make_real (shrinked_points[i][X_AXIS]);
-      SCM y = scm_make_real (shrinked_points[i][Y_AXIS]);
-      shrinked_points_scm = scm_cons (x, scm_cons (y, shrinked_points_scm));
+      SCM x = scm_make_real (shrunk_points[i][X_AXIS]);
+      SCM y = scm_make_real (shrunk_points[i][Y_AXIS]);
+      shrunk_points_scm = scm_cons (x, scm_cons (y, shrunk_points_scm));
       box.add_point (points[i]);
     }
   SCM polygon_scm = scm_list_n (ly_symbol2scm ("polygon"),
-                               ly_quote_scm (shrinked_points_scm),
+                               ly_quote_scm (shrunk_points_scm),
                                scm_make_real (blotdiameter),
                                SCM_BOOL_T,
                                SCM_UNDEFINED);
 
   Stencil polygon = Stencil (box, polygon_scm);
-  shrinked_points.clear ();
+  shrunk_points.clear ();
   return polygon;
 }
 
index 64bd1bf56afe42cac3cba210877347f0c3cbb2b4..b8f36aa208343c15912a4fba124bccc9f760d954 100644 (file)
@@ -149,33 +149,6 @@ bind def
        } ifelse
 } bind def
 
-% Nice beam with rounded corners
-/draw_beam % slope width thick  blot
-{
-       /blot exch def
-       blot setlinewidth
-
-       0 setlinecap
-       1 setlinejoin
-
-       blot sub /t exch def
-       blot sub /w exch def
-       w mul /h exch def
-
-       blot 2 div t 2 div neg moveto
-       w h rlineto
-       0 t rlineto
-       w neg h neg rlineto
-       0 t neg rlineto
-
-       currentdict /testing known {
-               %% outline only, for testing:
-               stroke
-       }{
-               closepath gsave stroke grestore fill
-       } ifelse
-} bind def
-
 /draw_polygon % x(n) y(n) x(n-1) y(n-1) ... x(1) y(1) n blot fill
 {
        /fillp exch def
index dfaff814405c0f367eb6eac902a3d2c5925c9724..18f9011fc522934325a8a9f3f6b6d7140cba0f28 100644 (file)
@@ -49,6 +49,7 @@ descend in the context tree.")
      (force-accidental ,boolean? "If set, a cautionary accidental should always be printed on this note")
      (grob-property ,symbol? "The symbol of the grob property to set. ")
      (grob-value ,scheme? "The value of the grob property to set")
+     (input-tag ,scheme? "Arbitrary marker to relate input and output")
      (inversion ,boolean? "If set, this chord note is inverted.")
      (label ,markup? "label of a mark.")
      (last-pitch ,ly:pitch? "The last pitch after relativization.")
index eddab1e1a33822deb1452efed0d36e422263f46e..589cfbf3cbe77f35cbc4105d0dce87e6c190757d 100644 (file)
@@ -194,54 +194,6 @@ lilypond -fgnome input/simple-song.ly
       (ly:all-stencil-expressions)
       (ly:all-output-backend-commands)))
 
-(define (beam width slope thick blot)
-  (define cursor '(0 . 0))
-  (define (rmoveto def x y)
-    (set! cursor (cons (+ x (car cursor)) (+ y (cdr cursor))))
-    (moveto def (car cursor) (cdr cursor)))
-  (define (rlineto def x y)
-    (set! cursor (cons (+ x (car cursor)) (+ y (cdr cursor))))
-    (lineto def (car cursor) (cdr cursor)))
-  (let* ((def (make <gnome-canvas-path-def>))
-        (bezier (make <gnome-canvas-bpath>
-                  #:parent (canvas-root)
-                  #:fill-color "black"
-                  #:outline-color "black"
-                  #:width-units blot
-                  #:join-style 'round))
-        (t (- thick blot))
-        (w (- width blot))
-        (h (* w slope)))
-    
-    (reset def)
-    (rmoveto def (/ blot 2) (/ t 2))
-    (rlineto def w (- h))
-    (rlineto def 0 (- t))
-    (rlineto def (- w) h)
-    (rlineto def 0 t)
-    (closepath def)
-    (set-path-def bezier def)
-    bezier))
-
-(define (square-beam width slope thick blot)
-  (let* ((def (make <gnome-canvas-path-def>))
-        (y (* (- width) slope))
-        (props (make <gnome-canvas-bpath>
-                 #:parent (canvas-root)
-                 #:fill-color "black"
-                 #:outline-color "black"
-                 #:width-units 0.0)))
-    
-    (reset def)
-    (moveto def 0 0)
-    (lineto def width y)
-    (lineto def width (- y thick))
-    (lineto def 0 (- thick))
-    (lineto def 0 0)
-    (closepath def)
-    (set-path-def props def)
-    props))
-
 ;; two beziers
 (define (bezier-sandwich lst thick)
   (let* ((def (make <gnome-canvas-path-def>))
index 9c2e6908e7eca1d968f89c89db3ec0b493336a72..681fec17f0cdf63ff35e6fb94a09fc9fac01ccb4 100644 (file)
@@ -21,7 +21,6 @@
            blank
            circle
            dot
-           beam
            dashed-slur
            char
            setcolor
 ;;; Lily output interface, PostScript implementation --- cleanup and docme
 ;;;
 
-;;; Output-interface functions
-(define (beam width slope thick blot)
-  (string-append
-   (ly:numbers->string (list slope width thick blot)) " draw_beam" ))
-
 ;; two beziers
 (define (bezier-sandwich lst thick)
   (string-append 
index 74451f3aa89a2cfa69ed8b60c104ca284e12b1c1..52f80348ee3bc989f3b190f2fe7d3b88ef5c08b4 100644 (file)
   (format "drawline ~a ~a ~a ~a ~a"
          thick x1 y2 x2 y2))
 
+(define-public (polygon xy-coords blot do-fill)
+  (format "polygon ~a ~a ~a"
+         blot
+         (if do-fill "True" "False")
+         (string-join
+          (map number->string xy-coords))
+  ))
 
 (define-public (named-glyph font glyph)
-  (format "glyphshow ~a \"~a\" ~a"
+  (format "glyphshow ~a \"~a\" ~a \"~a\""
          (ly:font-glyph-name-to-charcode font glyph)
          (ly:font-name font)
          (modified-font-metric-font-scaling font)
+         glyph
          ))
 
 (define-public (placebox x y s) 
        (y (cdr offset))
        )
 
-    (list (+ x (car x-ext))
-         (+ y (car y-ext))
-         (+ x (cdr x-ext))
-         (+ y (cdr y-ext)))
-    ))
+    (map (lambda (x)
+          (if (inf? x) 0.0 x))
+        
+        (list (+ x (car x-ext))
+              (+ y (car y-ext))
+              (+ x (cdr x-ext))
+              (+ y (cdr y-ext)))
+    )))
 
 (define-public (no-origin)
   "nocause\n")
 
 (define-public (grob-cause offset grob)
   (let*
-      ((cause (music-cause grob)))
-  (if (and cause (integer? (ly:music-property cause 'input-tag)))
-      (apply format
-            (append
-             (list "cause ~a ~a ~a ~a ~a\n" (ly:music-property cause 'input-tag))
-             (grob-bbox grob offset)
-            ))
-      "")))
+      ((cause (music-cause grob))
+       (tag (if (and cause (integer? (ly:music-property cause 'input-tag)))
+               (ly:music-property cause 'input-tag)
+               -1))
+       (name (cdr (assoc 'name (ly:grob-property grob 'meta))))
+       )
+    
+    (apply format
+          (append (list "cause ~a \"~a\" ~a ~a ~a ~a\n"
+                        tag name)
+          
+                  (grob-bbox grob offset))
+         )))
 
 (define-public (glyph-string
         postscript-font-name
index 0b0ec7e66bad31fdd10baa3abedf9d6f34426be2..a1df2f474c0af4348a1ad8f1ff07f8b0fd51a572 100644 (file)
   "")
 
 
-(define (rect-beam width slope thick blot-diameter)
-  (let* ((x width)
-        (y (* slope width))
-        (z (/ y x)))
-    (entity 'rect ""
-           ;; The stroke will stick out.  To use stroke,
-           ;; the stroke-width must be subtracted from all other dimensions.
-           ;;'(stroke-linejoin . "round")
-           ;;'(stroke-linecap . "round")
-           ;;`(stroke-width . ,blot-diameter)
-           ;;'(stroke . "red")
-           ;;'(fill . "orange")
-
-           `(x . 0)
-           `(y . ,(- (/ thick 2)))
-           `(width . ,width)
-           `(height . ,(+ thick (* (abs z) (/ thick 2))))
-           `(rx . ,(/ blot-diameter 2))
-           `(transform . ,(format #f "matrix (1, ~f, 0, 1, 0, 0)"  z)
-                       ))))
-
-(define (beam width slope thick blot-diameter)
-  (let* ((b blot-diameter)
-        (t (- thick b))
-        (w (- width b))
-        (h (* w slope)))
-    (entity 'polygon ""
-           '(stroke-linejoin . "round")
-           '(stroke-linecap . "round")
-           `(stroke-width . ,blot-diameter)
-           '(stroke . "currentColor")
-           '(fill . "currentColor")
-           `(points . ,(string-join
-                        (map offset->point
-                             (list (cons (/ b 2) (/ t 2))
-                                   (cons (+ w (/ b 2)) (+ h (/ t 2)))
-                                   (cons (+ w (/ b 2)) (+ h (- (/ t 2))))
-                                   (cons (/ b 2) (- (/ t 2)))))))
-           )))
-
-(define (path-beam width slope thick blot-diameter)
-  (let* ((b blot-diameter)
-        (t (- thick b))
-        (w (- width b))
-        (h (* w slope)))
-    (entity 'path ""
-           '(stroke-linejoin . "round")
-           '(stroke-linecap . "round")
-           `(stroke-width . ,blot-diameter)
-           '(stroke . "currentColor")
-           '(fill . "currentColor")
-           `(d . ,(format #f "M ~S,~S l ~S,~S l ~S,~S l ~S,~S l ~S,~S"
-                          (/ b 2) (/ t 2)
-                          w (- h)
-                          0 (- t)
-                          (- w) h
-                          0 t))
-           )))
 
 (define (bezier-sandwich lst thick)
   (let* ((first (list-tail lst 4))
 
 (define (placebox x y expr)
   (entity 'g
+         
          ;; FIXME -- JCN
          ;;(dispatch expr)
          expr
index 690ed6d2d9b08a07b798a5f8499345535da72214..01dfeb40335af6c6057a0c6a32ad631d23d85c1a 100644 (file)
@@ -24,7 +24,6 @@
            blank
            circle
            dot
-           beam
            dashed-slur
            named-glyph
            dashed-line
@@ -79,9 +78,6 @@
 (define (embedded-ps string)
   (embedded-ps (list 'embedded-ps string)))
 
-(define (beam width slope thick blot)
-  (embedded-ps (list 'beam  width slope thick blot)))
-
 (define (dashed-slur thick on off lst)
   (embedded-ps (list 'dashed-slur thick on off `(quote ,lst))))