use guile to set specific extra-offset values if stem direction is up or down
Hello, I'm dealing with special noteheads I've designed and I need to move the stem and the flag differently if stem direction is up or down. I would like to create a guile lisp clause that sets the extra-offset value accordingly to the Stem position. I was trying this, but it does not work... \once \override Stem #'extra-offset = #(if (eqv? ly:stem::calc-direction UP) '(-0.02 . -0.25) '(0.02 . 0.25)) (also tried this... \once \override Stem #'extra-offset = #(if (ly:dir? ly:stem::calc-direction UP) '(-0.02 . -0.25) '(0.02 . 0.25)) ) any tips? thanks josé -- http://zepadovani.info ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: use guile to set specific extra-offset values if stem direction is up or down
Hi José, On Mon, May 21, 2012 at 9:09 AM, padovani zepadovani.li...@gmail.comwrote: Hello, I'm dealing with special noteheads I've designed and I need to move the stem and the flag differently if stem direction is up or down. I would like to create a guile lisp clause that sets the extra-offset value accordingly to the Stem position. I was trying this, but it does not work... \once \override Stem #'extra-offset = #(if (eqv? ly:stem::calc-direction UP) '(-0.02 . -0.25) '(0.02 . 0.25)) (also tried this... \once \override Stem #'extra-offset = #(if (ly:dir? ly:stem::calc-direction UP) '(-0.02 . -0.25) '(0.02 . 0.25)) ) any tips? You're almost there, but ly:stem::calc-direction is a procedure which needs the Stem grob as its argument. So you can do this: \version 2.14.2 \relative c'' { c c' \override Stem #'extra-offset = #(lambda (grob) (if (eqv? (ly:stem::calc-direction grob) UP) '(-0.02 . -0.25) '(0.02 . 0.25))) c, c' } BTW, you could also use ly:grob-property here to get the direction of the stem: \override Stem #'extra-offset = #(lambda (grob) (if (eq? (ly:grob-property grob 'direction) UP) '(-0.02 . -0.25) '(0.02 . 0.25))) HTH, David ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: use guile to set specific extra-offset values if stem direction is up or down
Em 5/21/12 11:44 AM, David Nalesnik escreveu: \override Stem #'extra-offset = #(lambda (grob) (if (eqv? (ly:stem::calc-direction grob) UP) '(-0.02 . -0.25) '(0.02 . 0.25))) Hello David, thank you very much! Now I see that ly:stem::calc-direction only gives me the standard Stem direction, but if I am using some \stemDown or \stemUp before the note, the lambda function will ignore the actual direction of the Stem and adjust stem offsets accordingly to the standard direction. Do you (or anybody else) know a way to access the actual direction of the Stem? Thank you again! José -- http://zepadovani.info ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: use guile to set specific extra-offset values if stem direction is up or down
Hi José, On Mon, May 21, 2012 at 10:20 AM, padovani zepadovani.li...@gmail.comwrote: Em 5/21/12 11:44 AM, David Nalesnik escreveu: \override Stem #'extra-offset = #(lambda (grob) (if (eqv? (ly:stem::calc-direction grob) UP) '(-0.02 . -0.25) '(0.02 . 0.25))) Hello David, thank you very much! Now I see that ly:stem::calc-direction only gives me the standard Stem direction, but if I am using some \stemDown or \stemUp before the note, the lambda function will ignore the actual direction of the Stem and adjust stem offsets accordingly to the standard direction. Do you (or anybody else) know a way to access the actual direction of the Stem? Yes, in this instance the second option I gave (using ly:grob-property to look up 'direction) will give you the proper direction after a \stemUp or \stemDown. -David ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: use guile to set specific extra-offset values if stem direction is up or down
Oh, I'm sorry... I was reading everything in a hurry and didn't got the second part of your message. Thank you again! 2012/5/21 David Nalesnik david.nales...@gmail.com Hi José, On Mon, May 21, 2012 at 10:20 AM, padovani zepadovani.li...@gmail.comwrote: Em 5/21/12 11:44 AM, David Nalesnik escreveu: \override Stem #'extra-offset = #(lambda (grob) (if (eqv? (ly:stem::calc-direction grob) UP) '(-0.02 . -0.25) '(0.02 . 0.25))) Hello David, thank you very much! Now I see that ly:stem::calc-direction only gives me the standard Stem direction, but if I am using some \stemDown or \stemUp before the note, the lambda function will ignore the actual direction of the Stem and adjust stem offsets accordingly to the standard direction. Do you (or anybody else) know a way to access the actual direction of the Stem? Yes, in this instance the second option I gave (using ly:grob-property to look up 'direction) will give you the proper direction after a \stemUp or \stemDown. -David ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: use guile to set specific extra-offset values if stem direction is up or down
José, On Mon, May 21, 2012 at 11:02 AM, padovani zepadovani.li...@gmail.comwrote: Oh, I'm sorry... I was reading everything in a hurry and didn't got the second part of your message. No problem! I learned something new about ly:stem::calc-direction because of your email: didn't know that it calculates ideal directions. -David ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: use guile to set specific extra-offset values if stem direction is up or down
Hi again, so.. as the flags are now separate objects (2.15.38), I'm having problems to move them to the same place that I am moving the stems... if I just reproduce the lambda function I am using with Stems with flags, it does not work... \once \override Stem #'extra-offset = #(lambda (grob) (if (eq? (ly:grob-property grob 'direction) UP) '(-0.02 . -0.25) '(0.02 . 0.25))) %this fails \once \override Flag #'extra-offset = #(lambda (grob) (if (eq? (ly:grob-property grob 'direction) UP) '(-0.02 . -0.25) '(0.02 . 0.25))) So, is there a way to know the Flag direction? Or maybe a wat to access the Stem's grob from the Flag one (so that I can point the function to the Stem properties?). Thank you again, José Em 5/21/12 1:10 PM, David Nalesnik escreveu: José, On Mon, May 21, 2012 at 11:02 AM, padovani zepadovani.li...@gmail.com mailto:zepadovani.li...@gmail.com wrote: Oh, I'm sorry... I was reading everything in a hurry and didn't got the second part of your message. No problem! I learned something new about ly:stem::calc-direction because of your email: didn't know that it calculates ideal directions. -David -- http://zepadovani.info ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: use guile to set specific extra-offset values if stem direction is up or down
Hi José, On Mon, May 21, 2012 at 12:25 PM, padovani zepadovani.li...@gmail.comwrote: Hi again, so.. as the flags are now separate objects (2.15.38), I'm having problems to move them to the same place that I am moving the stems... if I just reproduce the lambda function I am using with Stems with flags, it does not work... \once \override Stem #'extra-offset = #(lambda (grob) (if (eq? (ly:grob-property grob 'direction) UP) '(-0.02 . -0.25) '(0.02 . 0.25))) %this fails \once \override Flag #'extra-offset = #(lambda (grob) (if (eq? (ly:grob-property grob 'direction) UP) '(-0.02 . -0.25) '(0.02 . 0.25))) So, is there a way to know the Flag direction? Or maybe a wat to access the Stem's grob from the Flag one (so that I can point the function to the Stem properties?). It would be possible to offset both of them, but I think you might be better served by approaching the problem from a different angle. You can control the relative positioning of stem and note head through 'stem-attachment, which is a property of NoteHead. The flag will move along with the stem. Also, the stem will end in the same place as an ordinary stem. Try this (the color override is useful to show the start of the stem): \version 2.15.38 customStemAndFlag = \once \override NoteHead #'stem-attachment = #(lambda (grob) (if (eq? (ly:grob-property grob 'direction) UP) '(-0.5 . -0.5)) '(0.5 . 0.5)) \relative c'' { %\override Stem #'color = #red \stemUp c8 \noBeam \customStemAndFlag c \stemDown c \noBeam \customStemAndFlag c } HTH, David Thank you again, José Em 5/21/12 1:10 PM, David Nalesnik escreveu: José, On Mon, May 21, 2012 at 11:02 AM, padovani zepadovani.li...@gmail.com mailto:zepadovani.lists@**gmail.com zepadovani.li...@gmail.com wrote: Oh, I'm sorry... I was reading everything in a hurry and didn't got the second part of your message. No problem! I learned something new about ly:stem::calc-direction because of your email: didn't know that it calculates ideal directions. -David -- http://zepadovani.info ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: use guile to set specific extra-offset values if stem direction is up or down
Hi again, It would be possible to offset both of them, but I think you might be better served by approaching the problem from a different angle. You can control the relative positioning of stem and note head through 'stem-attachment, which is a property of NoteHead. The flag will move along with the stem. Also, the stem will end in the same place as an ordinary stem. Try this (the color override is useful to show the start of the stem): Oh, that was a little too hasty of me! Note heads don't have direction, so all you need is this: customStemAndFlag = \once \override NoteHead #'stem-attachment = #'(0.5 . 0.5) Sorry to take the Scheme fun out of it... (if this is in fact gives you what you want!) -David ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: use guile to set specific extra-offset values if stem direction is up or down
Em 5/21/12 3:03 PM, David Nalesnik escreveu: Sorry to take the Scheme fun out of it... (if this is in fact gives you what you want!) That's it! No need of the Scheme part of the Scheme fun! :) Thank you very much! -- http://zepadovani.info ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel