|
| 1 | +//============================================================================= |
| 2 | +// Black notes : Paint all notes in black |
| 3 | +// http://musescore.org/en/project/blacknotes |
| 4 | +// |
| 5 | +// Copyright (C)2010 Nicolas Froment (lasconic) |
| 6 | +// |
| 7 | +// This program is free software; you can redistribute it and/or modify |
| 8 | +// it under the terms of the GNU General Public License version 2. |
| 9 | +// |
| 10 | +// This program is distributed in the hope that it will be useful, |
| 11 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | +// GNU General Public License for more details. |
| 14 | +// |
| 15 | +// You should have received a copy of the GNU General Public License |
| 16 | +// along with this program; if not, write to the Free Software |
| 17 | +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 18 | +//============================================================================= |
| 19 | + |
| 20 | +//--------------------------------------------------------- |
| 21 | +// init |
| 22 | +//--------------------------------------------------------- |
| 23 | + |
| 24 | +function init() |
| 25 | + { |
| 26 | + } |
| 27 | + |
| 28 | +//------------------------------------------------------------------- |
| 29 | +// run |
| 30 | +//------------------------------------------------------------------- |
| 31 | + |
| 32 | +function run() |
| 33 | + { |
| 34 | + if (typeof curScore === 'undefined') |
| 35 | + return; |
| 36 | + |
| 37 | + var black = new QColor(0, 0, 0); |
| 38 | + var cursor = new Cursor(curScore); |
| 39 | + for (var staff = 0; staff < curScore.staves; ++staff) { |
| 40 | + cursor.staff = staff; |
| 41 | + for (var v = 0; v < 4; v++) { |
| 42 | + cursor.voice = v; |
| 43 | + cursor.rewind(); // set cursor to first chord/rest |
| 44 | + |
| 45 | + while (!cursor.eos()) { |
| 46 | + if (cursor.isChord()) { |
| 47 | + var chord = cursor.chord(); |
| 48 | + var n = chord.notes; |
| 49 | + for (var i = 0; i < n; i++) { |
| 50 | + var note = chord.note(i); |
| 51 | + if (note.color != black) |
| 52 | + note.color = black; |
| 53 | + } |
| 54 | + } |
| 55 | + cursor.next(); |
| 56 | + } |
| 57 | + } |
| 58 | + } |
| 59 | + } |
| 60 | + |
| 61 | +var mscorePlugin = { |
| 62 | + menu: 'Plugins.Notes.Color notes in black', |
| 63 | + init: init, |
| 64 | + run: run |
| 65 | + }; |
| 66 | + |
| 67 | +mscorePlugin; |
0 commit comments