Color note only for alterations

• Jun 16, 2019 - 14:53

Hi!
i tried to create a plugin. I used color note as source. I want to color note only if it's a sharp or a flat. I modified color note's plugin but it is always the original plugin which applies. I always have notes and color note in the menu.
I join the file to this post if someone knows what's wrong.
Thanks
Virginie

Attachment Size
color notes alterees.qml 5.18 KB

Comments

Just one point : the note must be colored if it's altered. If the C is sharp I want the note C to be orange not the sharp.
Sorry for my english, I hope it's understandable.

You have menuPath: "Plugins.Notes.Color Notes", that conflicts with the 'regular' color notes plugin, so change that to menuPath: "Plugins.Notes.Color Notes Alterations"
In

      function colorNote(note) {
            if (note.color == black)
                  note.color = colors[note.pitch % 12];
            else
                  note.color = black;
 
            if (note.accidental) {
                  if (note.accidental.color == black)
                        note.accidental.color = colors[note.pitch % 12];
                  else
                        note.accidental.color = black;
                  }
 
            for (var i = 0; i < note.dots.length; i++) {
                  if (note.dots[i]) {
                        if (note.dots[i].color == black)
                              note.dots[i].color = colors[note.pitch % 12];
                        else
                              note.dots[i].color = black;
                        }
                  }
         }

You're coloring note(head)s, accidentaly and augmentation dots, exactly like the color notes plugin does.
Instead try this:

      function colorNote(note) {
            if (note.accidental) {
                  if (note.color == black)
                        note.color = colors[note.pitch % 12];
                  else
                        note.color = black;
                  }
            for (var i = 0; i < note.dots.length; i++) {
                  if (note.accidental && note.dots[i]) {
                        if (note.dots[i].color == black)
                              note.dots[i].color = colors[note.pitch % 12];
                        else
                              note.dots[i].color = black;
                        }
                  }
         }

to color note(head)s and augmention dot, if the note has an accidental

Do you still have an unanswered question? Please log in first to post your question.