Re: Drawing a hexagon with a number inside

2013-09-03 Thread Thomas Morley
2013/9/3 Rachael Thomas Carlson rachael.thomas.carl...@gmail.com:
 Hello All:

 I am attempting to draw a hexagon with a number inside of it using markup.

 The attached png is essentially what I am attempting.  This is to be used in
 a TabStaff.  I am not worried about the whiteout = ##f in the png.  I just
 simply can't seem to figure out how to create a hexagon such as in the png.
 Though, again, it would be optimal to create this within a markup
 environment.

 I am able to modify the TabNoteHead stencil.  That is not the problem. I
 just need to figure out how to create a hexagon with a number inside of it
 using markup.

 Any ideas?

 Rachael



Hi Rachael,

Torsten once posted the code below in the german LilyPond-forum

\version 2.14.2

#(define-markup-command (draw-n-agon layout props corners radius arg)
  (number? number? markup?)
  #:category graphic
  #:properties ((thickness 1))
  (let* ((th (* (ly:output-def-lookup layout 'line-thickness)
   thickness))
 (alpha-step (if (= corners 0) 99 (/ (* 2 PI) (abs corners
 (alpha-start (if (= radius 0) (/ alpha-step 2) 0))
 (polypoints
  (let loop ((alpha alpha-start))
(if ( alpha (* 2 PI))
'()
(cons (* (abs radius) (sin alpha)) (cons (- 0 (* (abs
radius) (cos alpha)))
   (loop (+ alpha alpha-step)))
 (m (interpret-markup layout props arg))
 (x-ext (ly:stencil-extent m X))
 (y-ext (ly:stencil-extent m Y)))
(ly:stencil-add m
  (ly:stencil-translate
 (if (equal? polypoints '())
(ly:make-stencil (list 'circle radius th #f))
(ly:make-stencil `(polygon ',polypoints  ,th #f)))
 (cons (/ (cdr x-ext) 2) (/ (cdr y-ext) 2))


% TEST:

\header { tagline = ##f }
\paper { ragged-last-bottom = ##f }

\markup \draw-n-agon #100 #-4 3

\relative c' {
  \override Score.RehearsalMark #'padding = #4

% gleichseitige Dreiecke
  s1  \mark \markup \draw-n-agon #3 #4 3
  s  \mark \markup \draw-n-agon #3 #4 33
  s  \mark \markup \draw-n-agon #3 #-4 3
  s  \mark \markup \draw-n-agon #3 #-4 33
  s  \mark \markup \draw-n-agon #3 #4 \draw-n-agon #3 #-4 3
  s  \mark \markup \draw-n-agon #3 #4 \draw-n-agon #3 #-4 33
  s \break

% Quadrate
  s  \mark \markup \draw-n-agon #4 #3 4
  s  \mark \markup \draw-n-agon #4 #3 44
  s  \mark \markup \draw-n-agon #4 #-3 4
  s  \mark \markup \draw-n-agon #4 #-3 44
  s  \mark \markup \draw-n-agon #4 #3 \draw-n-agon #4 #-3 4
  s  \mark \markup \draw-n-agon #4 #3 \draw-n-agon #4 #-3 44
  s \break

% gleichseitige Pentagone
  s  \mark \markup \draw-n-agon #5 #2.5 5
  s  \mark \markup \draw-n-agon #5 #2.5 55
  s  \mark \markup \draw-n-agon #5 #-2.5 5
  s  \mark \markup \draw-n-agon #5 #-2.5 55
  s  \mark \markup \draw-n-agon #5 #2.5 \draw-n-agon #5 #-2.5 5
  s  \mark \markup \draw-n-agon #5 #2.5 \draw-n-agon #5 #-2.5 55
  s  \break

% gleichseitige Hexagone
  s  \mark \markup \draw-n-agon #6 #2.5 6
  s  \mark \markup \draw-n-agon #6 #2.5 66
  s  \mark \markup \draw-n-agon #6 #-2.5 6
  s  \mark \markup \draw-n-agon #6 #-2.5 66
  s  \break

% gleichseitige Heptagone
  s  \mark \markup \draw-n-agon #7 #2.5 7
  s  \mark \markup \draw-n-agon #7 #2.5 77
  s  \mark \markup \draw-n-agon #7 #-2.5 7
  s  \mark \markup \draw-n-agon #7 #-2.5 77
  s  \break

% gleichseitige Oktagone
  s  \mark \markup \draw-n-agon #8 #2.5 8
  s  \mark \markup \draw-n-agon #8 #2.5 88
  s  \mark \markup \draw-n-agon #8 #-2.5 8
  s  \mark \markup \draw-n-agon #8 #-2.5 88
  s  \break

% Kreise
  s  \mark \markup \draw-n-agon #0 #2.5 0
  s  \mark \markup \draw-n-agon #0 #2.5 00

% Kombinationen Quadrat und Dreieck
  s  \mark \markup \draw-n-agon #4 #2.5 \draw-n-agon #3 #5.5 9
  s  \mark \markup \draw-n-agon #4 #2.5 \draw-n-agon #3 #5.5 99
  s  \mark \markup \draw-n-agon #4 #5 \lower #1.5 \draw-n-agon #3 #3.5 9
  s  \mark \markup \draw-n-agon #4 #5 \lower #1.5 \draw-n-agon #3 #3.5 99
  s  \break

% Kombinationen Dreieck und Kreis
  s  \mark \markup \draw-n-agon #0 #1.9 \draw-n-agon #3 #4.5 9
  s  \mark \markup \draw-n-agon #0 #1.9 \draw-n-agon #3 #4.5 99
  s  \mark \markup \draw-n-agon #0 #2.5 \draw-n-agon #3 #3.5 9
  s  \mark \markup \draw-n-agon #0 #2.5 \draw-n-agon #3 #3.5 99
  s  \mark \markup \draw-n-agon #0 #3.5 \draw-n-agon #3 #3.5 9
  s  \mark \markup \draw-n-agon #0 #3.5 \draw-n-agon #3 #3.5 99
  s  \mark \markup \draw-n-agon #0 #4 \draw-n-agon #3 #3.5 9
  s  \mark \markup \draw-n-agon #0 #4 \draw-n-agon #3 #3.5 99
  s  \break

% Kombinationen Quadrat und Kreis
  s  \mark \markup \draw-n-agon #0 #2 \draw-n-agon #4 #4 9
  s  \mark \markup \draw-n-agon #0 #2 \draw-n-agon #4 #4 99
  s  \mark \markup \draw-n-agon #0 #2.5 \draw-n-agon #4 #3 9
  s  \mark \markup \draw-n-agon #0 #2.5 \draw-n-agon #4 #3 99
  s  \mark \markup \draw-n-agon #0 #3 \draw-n-agon #4 #3 9
  s  \mark \markup \draw-n-agon #0 #3 \draw-n-agon #4 #3 99
  s  \mark \markup \draw-n-agon #0 #3.5 \draw-n-agon #4 #3 9
  s  \mark \markup 

Re: Drawing a hexagon with a number inside

2013-09-03 Thread David Kastrup
Rachael Thomas Carlson rachael.thomas.carl...@gmail.com writes:

 Hello All:

 I am attempting to draw a hexagon with a number inside of it using markup.

 The attached png is essentially what I am attempting.  This is to be
 used in a TabStaff.  I am not worried about the whiteout = ##f in the
 png.  I just simply can't seem to figure out how to create a hexagon
 such as in the png.  Though, again, it would be optimal to create this
 within a markup environment.

 I am able to modify the TabNoteHead stencil.  That is not the
 problem. I just need to figure out how to create a hexagon with a
 number inside of it using markup.

 Any ideas?

Those are not actually proper hexagons, so they are pretty easy to draw
using something like

\markup \path #0.25 #'((moveto 3 0)
   (lineto 1 2)
   (lineto -1 2)
   (lineto -3 0)
   (lineto -1 -2)
   (lineto 1 -2)
   (closepath))

There needs to be scaling and matching to the content as well, of course.

-- 
David Kastrup


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Drawing a hexagon with a number inside

2013-09-03 Thread Carl Peterson
On Tue, Sep 3, 2013 at 1:44 PM, Rachael Thomas Carlson 
rachael.thomas.carl...@gmail.com wrote:


 I hate to use Arial but the publishing house that I am emulating uses only
 proprietary fonts.


There are a few non-proprietary fonts that emulate Arial much the same way
that Arial emulates Helvetica (can be confused by casual observer, but
obvious to those who know what to look for). Liberation Sans does a fairly
serviceable job, if I recall correctly. I think I used it a couple of times
in place of Arial recently.

Carl
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Drawing a hexagon with a number inside

2013-09-03 Thread Rachael Thomas Carlson

Hello David:

Thanks for the help.


Those are not actually proper hexagons, so they are pretty easy to draw
using something like

\markup \path #0.25 #'((moveto 3 0)
(lineto 1 2)
(lineto -1 2)
(lineto -3 0)
(lineto -1 -2)
(lineto 1 -2)
(closepath))

There needs to be scaling and matching to the content as well, of course.



here is what I came up with from your recommendation:

\markup { \override #'(font-name . Arial)
  {
\center-column {
\combine
\path #0.1 #'((moveto 0.9 0)
   (lineto 0.4 0.7)
   (lineto -0.4 0.7)
   (lineto -0.9 0)
   (lineto -0.4 -0.7)
   (lineto 0.4 -0.7)
   (closepath))
\override #'(font-size . -4)
\halign #CENTER
\raise #-0.5
7
}
  }
}

I hate to use Arial but the publishing house that I am emulating uses 
only proprietary fonts.


Thank you for the help!

Rachael

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Drawing a hexagon with a number inside

2013-09-03 Thread Rachael Thomas Carlson




Hope it's still working (didn't test it with newer versions)

It appears to work quite well with 2.16.2.  I will need more time with 
this document in order to make it do exactly what I want; but it is good 
know of all of the wonderful possibilities of markup and scheme.


It really makes me realize how much I need to start focusing on Scheme 
if I am going to really get anywhere with LilyPond.


Thank for your help.

Rachael

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user