Re: Keyboard chord figure in scheme

2012-01-18 Thread m...@apollinemike.com
On Jan 18, 2012, at 9:16 AM, Morten Jagd Christensen wrote:

> Now the code works, although there still are som FIXME's. For example the 
> black keys
> are generated by thick lines, but unfortunately they have rounded caps.
> 
> 

Check out make-connected-path-stencil : the swiss army knife of stencils.

A brief API :
(make-connected-path-stencil pointlist thickness x-scale y-scale connect fill)

Where pointlist is a list of lists.  Each list in the list has either 2-points 
(line) or 6 points (Bezier curve).  Since you are just working with lines, 
you'd use lists of 2.
So, if you use (make-connected-path-stencil '((3 0) (3 10) (0 10) (0 0)) 0.1 1 
1 #f #t) you'll get a black rectangle of dimensions 3 x 10.
With (make-connected-path-stencil '((3 0) (3 10) (0 10) (0 0)) 0.1 1 1 #f #f) 
you'll get a white rectangle of dimensions 3 x 10.  This avoids the rounded 
caps to which you refer.

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


Re: Keyboard chord figure in scheme

2012-01-18 Thread Morten Jagd Christensen

Hi Carl

Thanks for the hint - I guess it wasn't clear to me when and where 
ly:stencil-add was

needed.

Now the code works, although there still are som FIXME's. For example 
the black keys

are generated by thick lines, but unfortunately they have rounded caps.

But I have submitted my code to the snippet repository any way, so 
hopefully

others can benefit from your help too.

Cheers

/Morten



On 18/1/12 2:55 AM, Carl Sorensen wrote:

On 1/17/12 2:30 PM, "Morten Jagd Christensen"  wrote:


Hello all

I'm trying to make a scheme function that generates a keyboard with
black and white dots for showing specific chord layouts

The code below compiles and produces the keyboard figure

I then call a function (make-dot key) which works fine. What I really
want is
(make-dot-list '(1 5 8))  which should produce a black dot on c, a white
dot on ees and a
black dot on g (for a C major chord).

I suspect that somehow only the last empty-stencil is returned but have
been unable
to solve my problem.

Does anyone have a suggestion how to solve this?


First of all, congratulations on this attempt. It's very good.

You are correct.  You are only returning the empty stencil.

You need the following:

#(define (make-dot-list l1)
(if (null? l1)
empty-stencil
(ly:stencil-add (make-dot (car l1)
(make-dot-list (cdr l1

This way, you are adding all the stencils.  Previously, you were not doing
anything with the make-dot stencil.  It was getting created, then thrown
away.


Good luck!


Carl



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


Re: Keyboard chord figure in scheme

2012-01-17 Thread Carl Sorensen
On 1/17/12 2:30 PM, "Morten Jagd Christensen"  wrote:

>Hello all
>
>I'm trying to make a scheme function that generates a keyboard with
>black and white dots for showing specific chord layouts
>
>The code below compiles and produces the keyboard figure
>
>I then call a function (make-dot key) which works fine. What I really
>want is
>(make-dot-list '(1 5 8))  which should produce a black dot on c, a white
>dot on ees and a
>black dot on g (for a C major chord).
>
>I suspect that somehow only the last empty-stencil is returned but have
>been unable
>to solve my problem.
>
>Does anyone have a suggestion how to solve this?


First of all, congratulations on this attempt. It's very good.

You are correct.  You are only returning the empty stencil.

You need the following:

#(define (make-dot-list l1)
   (if (null? l1) 
   empty-stencil
   (ly:stencil-add (make-dot (car l1)
   (make-dot-list (cdr l1

This way, you are adding all the stencils.  Previously, you were not doing
anything with the make-dot stencil.  It was getting created, then thrown
away.


Good luck!


Carl


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