FabricJS does not have a native method for obtaining pixel colors.
The workaround is to use your own html5 canvas to extract pixel data:
Create Fabric Image Objects. Be sure to specify crossOrigin as "anonymous", otherwise the canvas will be corrupted by a security violation, and then the pixel data will not be available.
Listen to the Fabric mouse: move event. When it fires, find the current mouse position and use your own canvas context.getImageData to get this color array of pixels.
Good luck with your project!
Here's the annotated code and demo:
body { background-color: ivory; } canvas { border: 1px solid red; }
<script src="http://cdnjs.cloudflare.com/ajax/libs/fabric.js/1.4.0/fabric.min.js"></script> <p id="results">Move mouse over canvas</p> <canvas id=canvas width=300 height=300></canvas>
markE source share