Fabric.js is a JavaScript canvas library that simplifies canvas rendering and provides an interactive object model for canvas elements. It allows creating and manipulating canvas elements and objects in a more simplified way compared to using the native canvas API. The library provides features like animation, events, SVG parsing, text rendering, and supports multiple browsers. Future plans include reducing the library size, improving documentation, and adding touch support.
Features — Events
object:scaled
object:selected fabric.util.observeEvent('object:moved', function(e) {
object:moved var activeObject = e.memo.target;
console.log(activeObject.left, activeObject.top);
group:modified });
group:selected
before:group:destroyed
after:group:destroyed
mouse:up
selection:cleared Will be made more consistent!
path:created
22.
Features — Text
fontsize
var myText = new fabric.Text('Hello world', {
font weight
fontfamily: 'delicious'
fontfamily
});
fontStyle
canvas.add(myText);
textDecoration
textShadow
lineHeight
backgroundColor
strokeStyle Will be made more consistent!
strokeWidth
Canvas libraries
Unit Tests
Hard to come across a library that has them
33.
Canvas libraries
easel.js
Probably the most active, similar, and
promising alternative.
But no unit tests or SVG parser :(
34.
Fabric use cases
mouse-based interactions built in
Collages
might be overkill for static charts
Basic games
Charts
Basic drawing (paintbrush, diagrams)
Display SVG where unsupported (Android)