Re: Tie/slur variable thickness vs shape

2020-05-22 Thread Pierre Perol-Schneider
Yes it does, thank you Kevin!
Cheers,
Pierre

Le ven. 22 mai 2020 à 09:21, Kevin Barry  a écrit :

> On Fri, 2020-05-22 at 07:16 +0200, Pierre Perol-Schneider wrote:
> > Hi,
> > I'm using Abraham's function: http://lsr.di.unimi.it/LSR/Item?id=1028
> > However, the overrides are killed by the shape adjustment:
> >
> > Any idea how to avoid that?
> > TIA, cheers,
> > Pierre
>
> Hi Pierre,
>
> Does this solve the problem?
>
> %%%
> \version "2.20.0"
>
> #(define (variable-bow-thickness min-l max-l min-t max-t)
>(lambda (grob)
>  (let* (;; get the procedure to calculate the control-points
>  (cpf (assoc-get 'control-points (ly:grob-basic-properties
> grob)))
>  (cpt (cond ((list? cpf) cpf)
> ((procedure? cpf) (cpf grob))
> ((ly:unpure-pure-container? cpf)
>  (ly:unpure-call cpf grob
>  (cp0 (car cpt))
>  (cp3 (cadddr cpt))
>  (dx (- (car cp3) (car cp0)))
>  (dy (- (cdr cp3) (cdr cp0)))
>  (len (magnitude (make-rectangular dx dy)))
>  ;; return a value for thickness
>  ;;   below min-l -> min-l
>  ;;   greater than max-l  -> max-l
>  ;;   between min-l and max-l -> calculate a nice value
>  (thickness
>   (cond ((< len min-l) min-t)
> ((> len max-l) max-t)
> (else
>  (+ min-t
> (* (- len min-l)
>(/ (- max-t min-t)
>   (- max-l min-l
>thickness)))
>
> \layout {
>   ragged-last = ##f
>   \override PhrasingSlur.thickness = #(variable-bow-thickness 6 25 1 3)
>   \override Slur.thickness = #(variable-bow-thickness 6 25 1 3)
>   \override Tie.thickness = #(variable-bow-thickness 6 18 1 2)
> }
>
> %% Test:
> {
>   \shape #'((0 . 0) (0 . 0) (0 . 0) (0 . 0)) Tie
>   \shape #'((0 . 0) (0 . 0) (0 . 0) (0 . 0)) Slur
>   \shape #'((0 . 0) (0 . 0) (0 . 0) (0 . 0)) PhrasingSlur
>   c''1~\(( 1 1 1) 1 1\)
> }
> %%
> %%%
>
> Kevin
>
>


Re: Tie/slur variable thickness vs shape

2020-05-22 Thread Kevin Barry
On Fri, 2020-05-22 at 07:16 +0200, Pierre Perol-Schneider wrote:
> Hi,
> I'm using Abraham's function: http://lsr.di.unimi.it/LSR/Item?id=1028
> However, the overrides are killed by the shape adjustment:
> 
> Any idea how to avoid that?
> TIA, cheers,
> Pierre

Hi Pierre,

Does this solve the problem?

%%%
\version "2.20.0"

#(define (variable-bow-thickness min-l max-l min-t max-t) 
   (lambda (grob)
 (let* (;; get the procedure to calculate the control-points
 (cpf (assoc-get 'control-points (ly:grob-basic-properties
grob)))
 (cpt (cond ((list? cpf) cpf)
((procedure? cpf) (cpf grob))
((ly:unpure-pure-container? cpf)
 (ly:unpure-call cpf grob
 (cp0 (car cpt)) 
 (cp3 (cadddr cpt))
 (dx (- (car cp3) (car cp0)))
 (dy (- (cdr cp3) (cdr cp0)))
 (len (magnitude (make-rectangular dx dy)))
 ;; return a value for thickness
 ;;   below min-l -> min-l
 ;;   greater than max-l  -> max-l
 ;;   between min-l and max-l -> calculate a nice value
 (thickness
  (cond ((< len min-l) min-t)
((> len max-l) max-t)
(else 
 (+ min-t 
(* (- len min-l)
   (/ (- max-t min-t) 
  (- max-l min-l
   thickness)))

\layout { 
  ragged-last = ##f
  \override PhrasingSlur.thickness = #(variable-bow-thickness 6 25 1 3) 
  \override Slur.thickness = #(variable-bow-thickness 6 25 1 3) 
  \override Tie.thickness = #(variable-bow-thickness 6 18 1 2)
}

%% Test:
{
  \shape #'((0 . 0) (0 . 0) (0 . 0) (0 . 0)) Tie
  \shape #'((0 . 0) (0 . 0) (0 . 0) (0 . 0)) Slur
  \shape #'((0 . 0) (0 . 0) (0 . 0) (0 . 0)) PhrasingSlur
  c''1~\(( 1 1 1) 1 1\)
}
%%
%%%

Kevin




Tie/slur variable thickness vs shape

2020-05-21 Thread Pierre Perol-Schneider
Hi,
I'm using Abraham's function: http://lsr.di.unimi.it/LSR/Item?id=1028
However, the overrides are killed by the shape adjustment:

%%
\version "2.20.0"

#(define (variable-bow-thickness min-l max-l min-t max-t)
  (lambda (grob)
(let (;; get the procedure to calculate the control-points
  (cpf (assoc-get 'control-points (ly:grob-basic-properties grob
  (if (procedure? cpf)
  (let* (;; get first and last control-point to calculate the length
 ;; of the bow
 (cpt (cpf grob))
 (cp0 (car cpt))
 (cp3 (cadddr cpt))
 (dx (- (car cp3) (car cp0)))
 (dy (- (cdr cp3) (cdr cp0)))
 (len (magnitude (make-rectangular dx dy)))
 ;; return a value for thickness
 ;;   below min-l -> min-l
 ;;   greater than max-l  -> max-l
 ;;   between min-l and max-l -> calculate a nice value
 (thickness
   (cond ((< len min-l) min-t)
 ((> len max-l) max-t)
 (else
   (+ min-t
 (* (- len min-l)
(/ (- max-t min-t)
   (- max-l min-l
;; print info in terminal
;(format #t "\n~a has \n\tlength ~a \n\tand \n\tthickness ~a"
;  grob
;  len
;  thickness)
thickness)
  ;; if no control-points can be calculated use default value
  1.2

\layout {
  ragged-last = ##f
  \override PhrasingSlur.thickness = #(variable-bow-thickness 6 25 1 3)
  \override Slur.thickness = #(variable-bow-thickness 6 25 1 3)
  \override Tie.thickness = #(variable-bow-thickness 6 18 1 2)
}

%% Test:
{
  %\shape #'((0 . 0) (0 . 0) (0 . 0) (0 . 0)) Tie
  %\shape #'((0 . 0) (0 . 0) (0 . 0) (0 . 0)) Slur
  %\shape #'((0 . 0) (0 . 0) (0 . 0) (0 . 0)) PhrasingSlur
  c''1~\(( 1 1 1) 1 1\)
}
%%

Any idea how to avoid that?
TIA, cheers,
Pierre