kangax/fabric.js — pull request #1098 by GordoRank (2014-01-15 11:22:33+00:00)
Title: Add optional automatic cursor coloring

Cursor is automatically colored depending on the pixel colors underneath the cursor. This accurately replicates the cursor functionality of native Windows applications such as MS Word.

Feature is initialized by setting ```cursorColor``` to ```'auto'```

Added optional property ```cursorColorDataEl``` which when passed an external canvas or image object will combine the pixels of the specified element with the pixels of the Fabric instance when determining the pixel colors for the cursor. This is very useful if the user is overlaying a Fabric instance over an external image or canvas. (e.g. A users application uses Fabric to provide text manipulation over the top of a photograph)

Example 1:
![ex1](https://f.cloud.github.com/assets/6388079/1919561/343f1b24-7dd6-11e3-8661-850a64947559.jpg)

The imagedata behind the cursor is extracted, inverted and then replaced ensuring that each pixel of the cursor is at the maximum contrast level to the pixels behind it.

Example 2:

![ex2](https://f.cloud.github.com/assets/6388079/1919588/912dc876-7dd6-11e3-8a80-d61640b9e274.jpg)

Cursor pixel color correctly reflects rotation/scaling

Example 3:
![ex3](https://f.cloud.github.com/assets/6388079/1919612/e4926990-7dd6-11e3-9b63-e9e58d16e9f0.jpg)

When the cursor is over another Fabric object the cursor pixel color is correctly updated