It is possible to color note heads depending on their pitch and/or their names: the function used in this example even makes it possible to distinguish enharmonics.
This is an alternate version of the original snippet found here: http://lsr.di.unimi.it/LSR/Item?id=572 This version achieves the same result by using different code that some may find easier to understand. (It uses case
rather than an association list to assign the colors.)