lilypond-user
[Top][All Lists]
Advanced

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

Re: conversion factor for \pt


From: Thomas Morley
Subject: Re: conversion factor for \pt
Date: Sun, 17 Mar 2013 02:10:10 +0100

2013/3/16 Trevor Daniels <address@hidden>:
[...]
> Does the example in
> http://www.lilypond.org/doc/v2.17/Documentation/notation/fonts#entire-document-fonts
> help?
>
> Trevor

A little, though:

Wanting to get a brace and a line having the same length in a markup,
I need to do some calculations, therefore I seem to need `pt` and
`staff-height´.

Well, I can do

\version "2.17.12"

\paper  {
  #(display "\n\t\tpt\t\t ")
  #(write pt)

  #(display "\n\t\tstaff-height\t ")
  #(write staff-height)
}

and the values are correct displayed, but trying that outside \paper
returns an error.
Seems these values are available in \paper only.
More:
I tried to write a markup-command using some recursive-function to get
the topmost ancestor for layout, though it returns already scaled
values. See
#(define-markup-command (dummy ...
below.

My current workaround is to define `my-pt´, `my-staff-height´ and
`my-line-thickness´ with empty values.
Than, from \paper I `set!´ these with the here available values.

The dummy-markup-command does two things:
a) It tries to read out the paper-values, but fails (as said above).
b) It uses the now present values of `my-pt´, `my-staff-height´ and
`my-line-thickness´ to do some calculations for printing a brace and a
line with the same height.


\version "2.16.2"

% Must be before \paper !!
#(set-global-staff-size 25)

#(define my-pt '())
#(define my-staff-height '())
#(define my-line-thickness '())

\paper  {
  #(display "\n\t\tpt\t\t ")
  #(write pt)

  #(display "\n\t\tstaff-height\t ")
  #(write staff-height)

  #(display "\n\n\t\ttest:")
  #(display "\n\t\t(* pt 20)\t ")
  #(write (* pt 20))

  #(display "\n\t\tline-thickness\t ")
  #(write line-thickness)

  #(set! my-pt pt)
  #(set! my-staff-height staff-height)
  #(set! my-line-thickness line-thickness)
}

#(define (looking-up layout props symbol)
   (define (ancestor layout)
     "Return the topmost layout ancestor"
     (let ((parent (ly:output-def-parent layout)))
       (if (not (ly:output-def? parent))
           layout
           (ancestor parent))))
      (ly:output-def-lookup (ancestor layout) symbol))

#(define-markup-command (dummy layout props size)
  (number?)
  "
   A dummy.
   Returns nearly equal sized brace and line.
   (Sometimes the brace is a little taller. That's ok.)
   Should display pt, staff-height, blot-diameter and line-thickness
   from paper.
   Though, it returns already scaled values.
  "
  (let* ((paper-pt (looking-up layout props 'pt))
         (paper-staff-height (looking-up layout props 'staff-height))
         (line-thickness (looking-up layout props 'line-thickness))
         (factor (* 2 my-pt my-staff-height))
         (mrkp (markup
                 ;#:box
                 #:left-brace (* (+ (* my-line-thickness 2) size) factor)
                 #:vcenter
                 ;#:box
                 #:draw-line `(0 . ,size)))

  )
  (display "\n\n\t======================================================\n")
  (display "\n\t\tpaper-pt\t\t ")(write paper-pt)
  (display "\n\t\tpaper-staff-height\t ")(write paper-staff-height)
  (display "\n\t\tline-thickness\t\t ")(write line-thickness)

  (interpret-markup layout props mrkp)))

\markup {
        \dummy #5
        bla bla bla
}



Best I can say: It works.
Though, in german I'd call this "Fischertechnik" (don't know if it's
understandable outside Germany, otoh, there's an english
wikipedia-article about it ...)

Is there no better method?


Thanks,
  Harm



reply via email to

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