-
Notifications
You must be signed in to change notification settings - Fork 662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
return noteheads after build #1590
return noteheads after build #1590
Conversation
Thank you. Just to add some context for this PR: If there are alternative approaches to achieve this goal without this change, please let me know. |
I also considered setting x and y as a part of Notehead initialization, however, I am concerned this will break dependent callers, as this approach gives default x and y values |
Now that I'm thinking about it a bit more, I guess I don't see the need for this. The noteheads are built automatically, and you can access them from the noteHeads property of stavenotes. Will that work? |
I have a use case where I need to draw a staveNote twice. The second time, I want to draw it in a different color. My solution is to use the
(Note: if I don't set x and y manually, I have a feeling what I do is not correct. I would appreciate any guidance on how to accomplish this more effectively. |
My feedback is "why not"? :-) The current function returns nothing, and if there is a better thing to return, then we should consider doing it. Otherwise, I don't see what's wrong with making this function slightly more convenient. I see that If we end up merging this, and it proves useful, we can cherrypick it over to V5 as well. |
@AaronDavidNewman @ronyeh |
Can you describe the use case a bit more, or provide an image showing the result you are looking for? So you want the exact same staveNote drawn twice on the staff, in different places? |
@accelerationa, if you just want to change the color of the note head, or animate it, it's probably easiest to do with CSS. Look at the style_tests.ts to see how to do this. It's not clear to us why you want to draw the note head twice, or what you're going to do with the x coordinate when you have it. To answer your question about X coordinate: you need to create a formatter and format the music before you have X coordinates. See fomatter_tests.ts, for instance the noteHeadPadding test, for how to do this. Once you have called formatter.format, you can use getAbsoluteX on stavenote and the note heads to get the X coordinate. The y is not available until after the notes are rendered. Until you have a formatter and had it format your voices, there are no coordinates associated with the notes at all, which is maybe why you are getting 0. Try to play around with the tests cases in the 'tests' directory, there is probably something there that is close to what you want to do. |
No description provided.