[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Lines to edges of \center-column
From: |
caagr98 |
Subject: |
Re: Lines to edges of \center-column |
Date: |
Sun, 23 Apr 2017 04:20:18 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.0 |
I did some further work on it. It looks pretty great, IMO. It works with left-
and right-aligning, too. No scaling horizontally (just 1sp margins), but it
automatically scales vertically.
```
#(define (expand-add pair n)
(cons (- (car pair) n) (+ (cdr pair) n)))
#(define (expand-mul mul pair)
(let* ((a (car pair))
(b (cdr pair))
(mid (/ (+ a b) 2))
(A (+ (* (- a mid) mul) mid))
(B (+ (* (- b mid) mul) mid)))
(cons A B)))
#(define (add-brackets mols th)
(define (line x1 y1 x2 y2)
(stencil-with-color
(make-line-stencil th x1 y1 x2 y2)
'(3/5 3/5 3/5)))
(let ((max-extent (ly:stencil-extent (car mols) X)))
(map (lambda (x)
(let ((stil-ext (ly:stencil-extent x X)))
(if (not (equal? max-extent stil-ext))
(let ((me (expand-add max-extent -2))
(se (expand-add stil-ext 1))
(ye (expand-mul 1/2 (ly:stencil-extent x Y))))
(if (< (car me) (car se))
(set! x
(ly:stencil-add
(line (car me) (car ye) (car se) (car ye))
(line (car me) (car ye) (car me) (cdr ye))
x)))
(if (> (cdr me) (cdr se))
(set! x
(ly:stencil-add
(line (cdr se) (car ye) (cdr me) (car ye))
(line (cdr me) (car ye) (cdr me) (cdr ye))
x))))))
x)
mols)))
#(define (general-column-bracket align-dir baseline mols)
(let* ((aligned-mols (map (lambda (x) (ly:stencil-aligned-to x X align-dir))
mols))
(aligned-mols (add-brackets aligned-mols 0.1))
(stacked-stencil (stack-lines -1 0.0 baseline aligned-mols))
(stacked-extent (ly:stencil-extent stacked-stencil X)))
(ly:stencil-translate-axis stacked-stencil (- (car stacked-extent)) X)))
#(define-markup-command (jp-column layout props args)
(markup-list?)
#:category align
#:properties ((baseline-skip))
(general-column-bracket CENTER baseline-skip (interpret-markup-list layout
props args)))
```
On 04/23/17 00:56, address@hidden wrote:
> This is great, thanks! I was trying to mess around with \hbracket and
> \whiteout, but this is far better.
>
> Just a few questions:
> Is it possible to scale the protrusions (and other things) by font size?
> How can I change the color of the lines?
> What does "mols" mean?
2017-04-23_04-16-01.png
Description: PNG image
- Re: Lines to edges of \center-column, (continued)
- Re: Lines to edges of \center-column, David Wright, 2017/04/22
- Re: Lines to edges of \center-column, caagr98, 2017/04/22
- Re: Lines to edges of \center-column, David Wright, 2017/04/22
- Re: Lines to edges of \center-column, caagr98, 2017/04/22
- Re: Lines to edges of \center-column, David Wright, 2017/04/24
- Re: Lines to edges of \center-column, caagr98, 2017/04/24
- Re: Lines to edges of \center-column, David Wright, 2017/04/25
Re: Lines to edges of \center-column, David Nalesnik, 2017/04/22