lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Get default value for grob properties


From: Thomas Morley
Subject: Re: Get default value for grob properties
Date: Wed, 4 Apr 2018 00:48:56 +0200

2018-04-03 14:39 GMT+02:00 Noeck <address@hidden>:
> Hi Kieren,
>
> thanks for pointing me to this long and interesting discussion.
> The codeĀ¹ worked pretty well for some grobs:
>   Staff.BarLine
> (hair-thickness is 1.9)
> but did not yield anything for
>   Staff.StaffSymbol or Staff.LedgerLineSpanner
>
> I am currently trying to export to SVG and measure the dimensions in
> Inkscape. Not very comfortable but it works.
>
> Cheers,
> Joram



Hi,

Staff.StaffSymbol.thickness is the thickness of the lines from which
the StaffSymbol is build.
Per default it's line-thickness from grob-layout multiplied with the
grob-thickness, defaulting  to 1, if unset.
Though, line-thickness from grob-layout is calculated as well, it's
not the same as line-thickness from \paper.

Easiest would be to use ly:staff-symbol-line-thickness.
(If nothing else helps have a look in the stencil-expression)

For further inside read and compile below.

For finding thickness of ledgers I'd go for StaffSymbol.ledger-line-thickness.
Both values you get, have impact, but I didn't followed them, take it
as an exercise ;)

At least it should be clear why it's not that easy like reading a
simple grob-property...

HTH a bit,
  Harm

#(define (get-actual-thickness grob)
  (let* ((grob-layout (ly:grob-layout grob))
         (line-thick (ly:output-def-lookup grob-layout 'line-thickness))
         (output-scale (ly:output-def-lookup grob-layout 'output-scale))
         (thick (ly:grob-property grob 'thickness 1))
         (paper-line-thickness
           (ly:output-def-lookup $defaultpaper 'line-thickness))
         (paper-output-scale
           (ly:output-def-lookup $defaultpaper 'output-scale)))
    (format #t "\n~y"
      (list
        ;(cons 'paper-line-thickness: paper-line-thickness)
        ;(cons 'paper-output-scale: paper-output-scale)
        ;;; same as
        ;;(cons 'grob-layout-output-scale output-scale)
        ;(cons 'devide-them::result: (/ paper-line-thickness
paper-output-scale))
        (cons 'grob-layout-line-thickness: line-thick)
        ;(cons 'grob-thickness thick)
        ;(cons '(* grob-thickness line-thickness) (* thick line-thick))
        ;(cons '(* (/ 0.3 output-scale) thick) (* (/ 0.3 output-scale) thick))
        ;; grob-line-thickness from stencil-expression
        (cadr (last (cadr (ly:stencil-expr (ly:grob-property grob 'stencil)))))
        ;; grob-line-thickness from `ly:staff-symbol-line-thickness'
        (ly:staff-symbol-line-thickness grob)
        ))))


mus = {
  \override Staff.StaffSymbol.after-line-breaking =
  #get-actual-thickness
  R1
}


%% Per default `line-thickness' and `output-scale' from \paper are used to
%% get the default `line-thickness' of the grob-layout:
%%   (/ paper-line-thickness paper-output-scale))
%%   ->  0.1
%\score {
%  \mus
%}

%% If you provide your own `line-thickness' then this value is taken:
%%   (/ (provided value: 0.3) paper-output-scale)
%%   ->  0.170716535433071,
\score {
  \mus
  \layout {
    line-thickness = 0.3
  }
}
%%
%% If you provide an own grob-thickness-value, then this value gets multiplied
%% with `line-thickness' of the grob-layout.
%%   (* grob-thickness line-thickness)
%%   -> 0.2
\score {
  \mus
  \layout {
    \override Staff.StaffSymbol.thickness = 2
  }
}

%% If you provide both, grob-thickness and layout-line-thickness then it's:
%%   (* (/ 0.3 output-scale) grob-thickness)
%%  -> 0.341433070866142
\score {
  \mus
  \layout {
    \override Staff.StaffSymbol.thickness = 2
    line-thickness = 0.3
  }
}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]