]> git.donarmstrong.com Git - lilypond.git/commitdiff
*** empty log message ***
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 18 Feb 2005 12:56:21 +0000 (12:56 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 18 Feb 2005 12:56:21 +0000 (12:56 +0000)
ChangeLog
lily/stencil.cc
lily/system.cc
scm/define-grob-properties.scm
scm/output-lib.scm
scm/output-ps.scm

index 64a929c38b1b7c6ad4ee5e05e22b518d67971f6b..bf4097206ca252d099638d7df735821e95c80f27 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2005-02-18  Erlend Aasland  <erlenda@gmail.com>
+
+       * input/regression/color.ly: new file
+
+       * lily/stencil.cc (interpret_stencil_expression):
+       when a color expression is encountered: save current color,
+       process the rest of the expression, and restore previous color.
+
+       * lily/system.cc (get_line): check all grobs for color property and
+       prepare the stencil scheme expressions for further processing.
+       Fix layer-loop.
+
+       * scm/define-grob-properties.scm: introduce the color property.
+
+       * scm/output-lib.scm: color helper functions.
+
+       * scm/output-ps.scm: introduce setcolor/resetcolor.
+
 2005-02-07  Erik Sandberg  <ersa9195@student.uu.se>
 
        * ly/*.ly, input/regression/*.ly: Added missing \version
index acdfd93bfab49c88cb9ef1d478499062464bf64c..0301cc1f5330b24e6beca50c99184635b4daf71c 100644 (file)
@@ -226,6 +226,19 @@ interpret_stencil_expression (SCM expr,
          (*func) (func_arg, scm_list_1 (ly_symbol2scm ("no-origin")));
          return;
        }
+      else if (head == ly_symbol2scm ("color"))
+       { 
+         SCM color = scm_cadr (expr);
+         SCM r = scm_car (color);
+         SCM g = scm_cadr (color);
+         SCM b = scm_caddr (color);
+
+         (*func) (func_arg, scm_list_4 (ly_symbol2scm ("setcolor"), r, g, b));
+         interpret_stencil_expression (scm_caddr (expr), func, func_arg, o);
+         (*func) (func_arg, scm_list_1 (ly_symbol2scm ("resetcolor")));
+   
+         return;
+       } 
       else
         {
           (*func) (func_arg,
index 68fcc8cdc4de5ac876636048dda895799c641656..7b8ff683496109eaf13d77642d07d5349f3050ab 100644 (file)
@@ -368,12 +368,10 @@ System::get_line ()
   SCM exprs = SCM_EOL;
   SCM *tail = &exprs;
 
-  /* Output stencils in three layers: 0, 1, 2.  Default layer: 1.
-
-     Start with layer 3, since scm_cons prepends to list.  */
+  /* Output stencils in three layers: 0, 1, 2.  Default layer: 1. */
   SCM all = get_property ("all-elements");
   
-  for (int i = LAYER_COUNT; i--;)
+  for (int i = 0; i < LAYER_COUNT; i++)
     for (SCM s = all; scm_is_pair (s); s = scm_cdr (s))
       {
        Grob *g = unsmob_grob (scm_car (s));
@@ -396,7 +394,16 @@ System::get_line ()
 
        Stencil st = *stil;
        st.translate (o + extra);
-       *tail = scm_cons (st.expr (), SCM_EOL);
+
+       /* color support... see interpret_stencil_expression() for more... */
+       SCM color = g->get_property ("color");
+       if (color != SCM_EOL)
+         { 
+               SCM tmp = scm_list_3 (ly_symbol2scm ("color"), color, st.expr ());
+               *tail = scm_cons (tmp, SCM_EOL);
+         }
+       else
+               *tail = scm_cons (st.expr (), SCM_EOL);
        tail = SCM_CDRLOC(*tail);
       }
 
index 311d40fb9e7e7695edf06984f365980d9035d4c3..23fb59f287bfc0a3c509675d4e6f04f9f80c07d0 100644 (file)
@@ -135,6 +135,8 @@ measure of the closeness of the inner stems. It is used for damping
 the slope of the beam.")
      (collapse-height ,ly:dimension? "Minimum height of system start delimiter.  If equal or smaller, the bracket is removed.")
 
+     (color ,color? "The color of this grob.")
+
      (context ,ly:context? "Originating context of the grob")
      
      ;;DOCME
index db5a1fb3b1761edb9a69d0bf825f0dca18abff15..a9249cc1732709dbf40052a201e2bd7e56750071 100644 (file)
@@ -262,3 +262,27 @@ centered, X==1 is at the right, X == -1 is at the left."
   "Shift an item to the right, but only at the start of the line."
   (if (and (ly:item? g)  (equal? (ly:item-break-dir g) RIGHT))
       (ly:grob-translate-axis! g 3.5 X)))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Color
+
+(define-public color? list?)
+
+; predefined colors
+(define-public black       '(0.0 0.0 0.0))
+(define-public white       '(1.0 1.0 1.0))
+(define-public red         '(1.0 0.0 0.0))
+(define-public green       '(0.0 1.0 0.0))
+(define-public blue        '(0.0 0.0 1.0))
+(define-public cyan        '(1.0 1.0 0.0))
+(define-public magenta     '(1.0 0.0 1.0))
+(define-public yellow      '(0.0 1.0 1.0))
+
+(define-public grey        '(0.5 0.5 0.5))
+(define-public darkred     '(0.5 0.0 0.0))
+(define-public darkgreen   '(0.0 0.5 0.0))
+(define-public darkblue    '(0.0 0.0 0.5))
+(define-public darkcyan    '(0.5 0.5 0.0))
+(define-public darkmagenta '(0.5 0.0 0.5))
+(define-public darkyellow  '(0.0 0.5 0.5))
index 67042e214e89a6e83065121c39a1ad0888325381..f682173e3aa3c513af79b34abed448e41ad62d7e 100644 (file)
@@ -27,6 +27,8 @@
            bracket
            dashed-slur
            char
+           setcolor
+           resetcolor
            named-glyph
            dashed-line
            zigzag-line
    (ps-font-command font) " setfont " 
    "(\\" (ly:inexact->string i 8) ") show"))
 
+;; save current color on stack and set new color
+(define (setcolor r g b)
+  (string-append "currentrgbcolor "
+  (ly:numbers->string (list r g b))
+  " setrgbcolor\n"))
+
+;; restore color from stack
+(define (resetcolor)
+  (string-append "setrgbcolor\n"))
+
 (define (dashed-line thick on off dx dy)
   (string-append 
    (ly:number->string dx) " "