[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Boxed text with rounded corners
From: |
Valentin Villenave |
Subject: |
Re: Boxed text with rounded corners |
Date: |
Tue, 1 Apr 2008 14:40:48 +0200 |
Greetings folks,
I have sent this mail on -user a few days ago; perhaps it would belong
to -devel instead (if so, please tell me), or even to the tracker as a
feature request (which I, of course, won't decide on my own).
Anyway, it would be just great if anybody had a clue about how to deal
with this issue? If so, the winner will have his solution exposed in a
whole new LSR-snippet, will be mentioned in the LilyPond Report's
"feature of the week" and his name will be glorified forever -- at
least until next week's :)
Valentin
2008/3/28, Valentin Villenave <address@hidden>:
> Hi everybody,
>
> There are two features (among others) I appreciate very much In
> LilyPond: \box and \filled-box.
>
> Would there be any possibility to somehow mix these two commands?
>
> For instance, is it possible to add an optionnal "blot" argument to
> the make-stencil-boxer function? If specified, the corners will be
> rounded; if not, the corners will be sharp.
>
> I tried to have a look at stencil.scm, define-markup-commands.scm,
> lookup.cc and text-interface.cc, but I am definitely not a programmer
> (see below).
>
> Here are some questions I couldn't solve:
>
> 1-how to obtain a non-filled rounded box? The only solution I can see would
> to:
> -draw a black-filled box slightly too large
> -then draw a white-filled box on top of it (#:whiteout or something?)
> -then print the text on the white box (#:combine or something?)
>
> It's complicated; however I found that some objects are already
> printed using this "dirty way:
> http://lists.gnu.org/archive/html/lilypond-devel/2006-04/msg00264.html
>
> 2-how exactly does ly:stencil-extent work? is it possible to obtain
> the width and length of an object *prior* to drawing it?
>
> 3-Here's some code to demonstrate my idea. It's very dirty but perhaps
> you'll see what I'm trying to achieve.
>
> #(define-markup-command (rbox layout props radius text) (number?) (markup?)
> "Add a rounded box around the text"
> (let* ((th (*
> (ly:output-def-lookup layout 'line-thickness)
> (chain-assoc-get 'thickness props 1)))
> (size (chain-assoc-get 'font-size props 0))
> (pad (* (magstep size)
> (chain-assoc-get 'box-padding props 0.2)))
> (m (interpret-markup layout props text)))
> (let* ((x-ext (interval-widen (ly:stencil-extent m 0) (+ pad th)))
> (y-ext (interval-widen (ly:stencil-extent m 1) (+ pad th)))
> (xext (cons (- (/ x-ext 2)) (/ x-ext 2)))
> (yext (cons (- (/ y-ext 2)) (/ y-ext 2)))
> (blot radius))
> (markup (ly:round-filled-box xext yext blot)))
> (let* ((x-ext (interval-widen (ly:stencil-extent m 0) pad))
> (y-ext (interval-widen (ly:stencil-extent m 1) pad))
> (xext (cons (- (/ x-ext 2)) (/ x-ext 2)))
> (yext (cons (- (/ y-ext 2)) (/ y-ext 2)))
> (blot radius))
> (markup #:with-color (rgb-color 1 1 1) #:filled-box xext yext blot))
> (markup m)))
>
> Besides, this could allow interesting Editorial uses: this way
> \balloonText could look like "real" balloons :)
>
> Cheers,
>
> Valentin
- Re: Boxed text with rounded corners,
Valentin Villenave <=