Allow custom coloring of individual notation elements on specific beats/notes #1769
Labels
area-rendering
Everything related to the rendering
platform-all
Affects all platforms
state-accepted
This is a valid topic to work on.
type-feature 💡
Motivation
There were repeating requests to allow "coloring of notes" from different users. Only a few users reported concrete use-cases on what exactly should be colored, how, and for what purpose. The use case makes sense but to ship the correct coloring of elements is not an easy task. The goal on the most recent request here is that individual notes should be colored for a music theory app. Coloring the notes allows referencing them in the descriptions like "the red note is a C"
Challenge
Here a very extreme case of notation elements related to a note. This should help understanding why "coloring a note" is more complex than initially expected. In this screenshot we see only 2 notes:
On the first beat:
Hence adding a single color property to notes or beats will not serve many use cases but rather only a very specific one.
Proposed Solution
By default the colors of the
renderingResources
still apply but on different levels of theScore
model, users can specify colors for specific notation elements. These colors would then be respected during rendering.Notes
public colors: Map<NoteElement, Color|null>;
on theNote
class wherenull
indicates a reset to the default color of therenderingResources
NoteElement
is an enumerations for the different elements where we want to support custom colors which are then respected by drawing.Beats
On the beat we follow the same principles like on notes but the elements to color would be specific to anything on beat level:
Voice
Voices on colors would be rather simple and override the color defined on
renderingResources
.Bars
On the bar we follow the same principles like on notes but the elements to color would be specific to anything on bar level:
Score
On the score we follow the same principles like on notes but the elements to color would be specific to anything on score level:
Performance Consideration
Accessing and changing colors for individual elements can have a quite significant performance impact. We want to avoid that in every glyph we have intensive code for checking for color changes and applying them.
We need some sort of "color container" taking care of providing the colors during rendering. Typically the performance should be on-par with the current logic, only if there are overrides they will have an impact during rendering (e.g. DOM parsing or updates on the rendering context).
The text was updated successfully, but these errors were encountered: