+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
(*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,
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));
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);
}
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
"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))
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) " "