Deutschsprachiges LilyPond-Forum

Allgemeine Fragen und Probleme => Fragen und Probleme aller Art => Thema gestartet von: Wabbe am Samstag, 25. September 2021, 11:32

Titel: Gelöst: Wie heißt das? Rhombus? rhomb? diamond? rotated-box?
Beitrag von: Wabbe am Samstag, 25. September 2021, 11:32
Liebe Leute,
Oft nutze ich grafische Sachen wie \box, \circle, \rouunded-box usw. Nun möchte ich Noten abtippen, in denen Zahlen (Taktzahlen) über den Noten in einem auf der Spitze stehenden Quadrat angezeigt werden. Weiß evtl. jemand, wie das notiert werden kann?
Danke an alle, die mitlesen.

Inzwischen habe ich gefunden, dass man sich so helfen kann: ^\markup   \rotate #45  \box \rotate #315  {2}

Und nochmal danke für's Mitlesen.
Titel: Antw:Gelöst: Wie heißt das? Rhombus? rhomb? diamond? rotated-box?
Beitrag von: harm6 am Sonntag, 26. September 2021, 11:11
Hallo,

Du könntest auch so vorgehen:

\version "2.22.1"

#(define* (diamond-stencil x thick #:optional (stretch-factor 4/3))
  (let* ((y (* x stretch-factor)))
    (ly:stencil-add
      (make-line-stencil thick (- x) 0 0 y)
      (make-line-stencil thick 0 y x 0)
      (make-line-stencil thick x 0 0 (- y))
      (make-line-stencil thick 0 (- y) (- x) 0))))
 
#(define-markup-command (diamond-box layout props mrkp)(markup?)
  #:properties ((thickness 1)
                (diamond-padding 0)
                (diamond-stretch-factor 4/3))
"Draw a diamond around @var{mrkp}.

The dimensions of the diamond are scaled to enclose @var{mrkp}, which is
regarded as a box.  Those dimensions are adjustable by overriding
@code{diamond-padding}.  @code{diamond-stretch-factor} determines how far the
resulting diamond is stretched."
  (let* ((arg-stil (interpret-markup layout props mrkp))
         (arg-x-ext (ly:stencil-extent arg-stil X))
         (arg-width (interval-length arg-x-ext))
         (arg-y-ext (ly:stencil-extent arg-stil Y))
         (arg-height (interval-length arg-y-ext))
         (thick
           (* (ly:output-def-lookup layout 'line-thickness) thickness))
         (diamond-x
           (+ diamond-padding
              (/ arg-width 2)
              (/ arg-height diamond-stretch-factor 2))))
    (ly:stencil-add
      arg-stil
      (ly:stencil-translate
        (diamond-stencil diamond-x thick diamond-stretch-factor)
        (cons
          (+ (car arg-x-ext) (/ arg-width 2))
          (+ (car arg-y-ext) (/ arg-height 2)))))))
   
   
\score {
  \repeat unfold 30 R1
  \layout {
  \context {
    \Score
    \override BarNumber.break-visibility = ##(#t #t #t)
    \override BarNumber.self-alignment-X = #CENTER
      \override BarNumber.before-line-breaking =
      #(lambda (grob)
        (let* ((txt (ly:grob-property grob 'text)))
          (ly:grob-set-property! grob 'text (markup #:diamond-box txt))))
  }
  }
}


Gruß,
  Harm
Titel: Antw:Gelöst: Wie heißt das? Rhombus? rhomb? diamond? rotated-box?
Beitrag von: Wabbe am Sonntag, 26. September 2021, 16:32
Vielen Dank, Harm6, ich staune immer wieder über die Expertise, die hier versammelt ist. Es finden sich immer gute Lösungen.

Zitat von: harm6 am Sonntag, 26. September 2021, 11:11
Hallo,

Du könntest auch so vorgehen:

\version "2.22.1"

#(define* (diamond-stencil x thick #:optional (stretch-factor 4/3))
  (let* ((y (* x stretch-factor)))
    (ly:stencil-add
      (make-line-stencil thick (- x) 0 0 y)
      (make-line-stencil thick 0 y x 0)
      (make-line-stencil thick x 0 0 (- y))
      (make-line-stencil thick 0 (- y) (- x) 0))))
 
#(define-markup-command (diamond-box layout props mrkp)(markup?)
  #:properties ((thickness 1)
                (diamond-padding 0)
                (diamond-stretch-factor 4/3))
"Draw a diamond around @var{mrkp}.

The dimensions of the diamond are scaled to enclose @var{mrkp}, which is
regarded as a box.  Those dimensions are adjustable by overriding
@code{diamond-padding}.  @code{diamond-stretch-factor} determines how far the
resulting diamond is stretched."
  (let* ((arg-stil (interpret-markup layout props mrkp))
         (arg-x-ext (ly:stencil-extent arg-stil X))
         (arg-width (interval-length arg-x-ext))
         (arg-y-ext (ly:stencil-extent arg-stil Y))
         (arg-height (interval-length arg-y-ext))
         (thick
           (* (ly:output-def-lookup layout 'line-thickness) thickness))
         (diamond-x
           (+ diamond-padding
              (/ arg-width 2)
              (/ arg-height diamond-stretch-factor 2))))
    (ly:stencil-add
      arg-stil
      (ly:stencil-translate
        (diamond-stencil diamond-x thick diamond-stretch-factor)
        (cons
          (+ (car arg-x-ext) (/ arg-width 2))
          (+ (car arg-y-ext) (/ arg-height 2)))))))
   
   
\score {
  \repeat unfold 30 R1
  \layout {
  \context {
    \Score
    \override BarNumber.break-visibility = ##(#t #t #t)
    \override BarNumber.self-alignment-X = #CENTER
      \override BarNumber.before-line-breaking =
      #(lambda (grob)
        (let* ((txt (ly:grob-property grob 'text)))
          (ly:grob-set-property! grob 'text (markup #:diamond-box txt))))
  }
  }
}


Gruß,
  Harm