retval = *m;
bool transparent = to_boolean (get_property ("transparent"));
+ /* Process whiteout before color and grob-cause to prevent colored */
+ /* whiteout background and larger file sizes with \pointAndClickOn. */
+ /* A grob has to be visible, otherwise the whiteout property has no effect. */
+ /* Calls the scheme procedure stencil-whiteout in scm/stencils.scm */
+ if (!transparent && (scm_is_number (get_property("whiteout"))
+ || to_boolean (get_property ("whiteout"))))
+ {
+ SCM wh_proc = ly_lily_module_constant ("stencil-whiteout");
+ Real thickness = robust_scm2double (get_property("whiteout"), 3.0)
+ * layout ()->get_dimension (ly_symbol2scm ("line-thickness"));
+ retval = *unsmob<Stencil> (scm_call_2 (wh_proc,
+ retval.smobbed_copy (),
+ scm_from_double (thickness)));
+ }
+
+ /* Calls the scheme procedure stencil-whiteout-box in scm/stencils.scm */
+ if (!transparent && to_boolean (get_property ("whiteout-box")))
+ {
+ SCM wh_proc = ly_lily_module_constant ("stencil-whiteout-box");
+ retval = *unsmob<Stencil> (scm_call_1 (wh_proc,
+ retval.smobbed_copy ()));
+ }
+
if (transparent)
retval = Stencil (m->extent_box (), SCM_EOL);
else
{
- SCM expr = m->expr ();
- expr = scm_list_3 (ly_symbol2scm ("grob-cause"),
- self_scm (), expr);
+ SCM expr = scm_list_3 (ly_symbol2scm ("grob-cause"),
+ self_scm (),
+ retval.expr ());
- retval = Stencil (m->extent_box (), expr);
+ retval = Stencil (retval.extent_box (), expr);
}
SCM rot = get_property ("rotation");
retval = Stencil (retval.extent_box (), expr);
}
- /* process whiteout */
- /* a grob has to be visible, otherwise the whiteout property has no effect */
- if (!transparent && to_boolean (get_property ("whiteout")))
- {
- /* Call the scheme procedure stencil-whiteout in scm/stencils.scm */
- /* to add a round-filled-box stencil to the stencil list */
- retval
- = *unsmob<Stencil> (scm_call_1 (ly_lily_module_constant ("stencil-whiteout"),
- retval.smobbed_copy ()));
- }
-
SCM id = get_property ("id");
if (scm_is_string (id))
{
"transparent "
"vertical-skylines "
"whiteout "
+ "whiteout-box "
);
/****************************************************************
;;; w
;;;
(when ,ly:moment? "Global time step associated with this column.")
- (whiteout ,boolean? "If true, the grob is printed over a white
-background to white-out underlying material, if the grob is visible.
- Usually #f by default.")
+ (whiteout ,boolean-or-number? "If a number or true, the grob is
+printed over a white background that follows the outline of the stencil,
+if the grob is visible. A number sets the thickness of the outline as a
+multiple of the staff-line thickness. For compatibility with former
+behavior (now available with @code{whiteout-box}) the value @code{#t} is
+treated as @code{3.0}. Usually @code{#f} by default.")
+ (whiteout-box ,boolean? "If true, the grob is printed over a
+rounded rectangular white background to white-out underlying material,
+if the grob is visible. Usually @code{#f} by default.")
(width ,ly:dimension? "The width of a grob measured in staff
space.")
(word-space ,ly:dimension? "Space to insert between words in
(define-markup-command (whiteout layout props arg)
(markup?)
#:category other
+ #:properties ((thickness 3))
"
@cindex adding a white background to text
\\markup {
\\combine
\\filled-box #'(-1 . 10) #'(-3 . 4) #1
- \\whiteout whiteout
+ \\override #'(thickness . 1.5) \\whiteout whiteout
}
@end lilypond"
- (stencil-whiteout (interpret-markup layout props arg)))
+ (stencil-whiteout
+ (interpret-markup layout props arg)
+ (* thickness
+ (ly:output-def-lookup layout 'line-thickness))))
+
+(define-markup-command (whiteout-box layout props arg)
+ (markup?)
+ #:category other
+ "
+@cindex adding a rounded rectangular white background to text
+
+Provide a rounded rectangular white background for @var{arg}.
+
+@lilypond[verbatim,quote]
+\\markup {
+ \\combine
+ \\filled-box #'(-1 . 10) #'(-3 . 4) #1
+ \\whiteout-box whiteout-box
+}
+@end lilypond"
+ (stencil-whiteout-box (interpret-markup layout props arg)))
(define-markup-command (pad-markup layout props amount arg)
(number? markup?)
(ly:stencil-extent stencil X)
(ly:stencil-extent stencil Y)))
-(define-public (stencil-whiteout stencil)
+(define*-public (stencil-whiteout
+ stil #:optional (thickness 0.3) (color white)
+ (angle-increments 16) (radial-increments 1))
+ "This function works by creating a series of white or @var{color}
+stencils radially offset from the original stencil with angles from
+0 to 2*pi, at an increment of @code{angle-inc}, and with radii
+from @code{radial-inc} to @var{thickness}. @var{thickness} is how big
+the white outline is in staff-spaces. @var{radial-increments} is how
+many copies of the white stencil we make on our way out to thickness.
+@var{angle-increments} is how many copies of the white stencil
+we make between 0 and 2*pi."
+ (if (or (not (positive? angle-increments))
+ (not (positive? radial-increments)))
+ (begin
+ (ly:warning "Both angle-increments and radial-increments must be positive numbers.")
+ stil)
+ (let* ((2pi 6.283185307)
+ (angle-inc (/ 2pi angle-increments))
+ (radial-inc (/ thickness radial-increments)))
+
+ (define (circle-plot ang dec radius original-stil new-stil)
+ ;; ang (angle) and dec (decrement) are in radians, not degrees
+ (if (<= ang 0)
+ new-stil
+ (circle-plot (- ang dec) dec radius original-stil
+ (ly:stencil-add
+ new-stil
+ (ly:stencil-translate original-stil
+ (cons
+ (* radius (cos ang))
+ (* radius (sin ang))))))))
+
+ (define (radial-plot radius original-stil new-stil)
+ (if (<= radius 0)
+ new-stil
+ (ly:stencil-add new-stil
+ (radial-plot
+ (- radius radial-inc)
+ original-stil
+ (circle-plot 2pi angle-inc
+ radius original-stil empty-stencil)))))
+
+ (let ((whiteout-expr
+ (ly:stencil-expr
+ (stencil-with-color
+ (radial-plot thickness stil empty-stencil)
+ color))))
+ (ly:stencil-add
+ (ly:make-stencil
+ `(delay-stencil-evaluation ,(delay whiteout-expr)))
+ stil)))))
+
+(define-public (stencil-whiteout-box stencil)
(let*
((x-ext (ly:stencil-extent stencil X))
- (y-ext (ly:stencil-extent stencil Y))
-
- )
+ (y-ext (ly:stencil-extent stencil Y)))
(ly:stencil-add
(stencil-with-color (ly:round-filled-box x-ext y-ext 0.0)
white)
- stencil)
- ))
+ stencil)))
(define-public (arrow-stencil-maker start? end?)
"Return a function drawing a line from current point to @code{destination},