HTML5 Canvas Drawing Library Introduction
Fabric.js is a JS framework for simplifying HTML5 canvas tag operations. This is an interactive object model on a canvas element. It is also a Svg-to-canvas parser. The following browsers are supported:
1.Firefox
2.Safari 3+
3.Opera 9.64+
4.Chrome (all versions should work)
5.ie9+
If we want to draw complex graphics on <canvas>, we need to learn a variety of geometric knowledge.
Fortunately, there are ready-made drawing libraries on the internet for our use, not only can easily draw round, triangle, ellipse, polygon and other basic graphics, but also provides a number of advanced methods. So that we don't have to draw any more, as long as we use these libraries, the bottom floor uses JavaScript to help us do the right <canvas>.
Here is an excellent library of drawings: fabric.js
1, Project Address
Website address: http://fabricjs.com/
github:https://github.com/kangax/fabric.js/
2, online sample
Demos
Kitchensink Demo
Benchmarks
3, simple use of the sample
Draws a red rectangle on the canvas.
<! DOCTYPE html>
<style>
Canvas {
border:1px dashed black;
}
</style>
<script src= "Dist/fabric.js" ></script>
<script>
Window.onload = function () {
var canvas = new fabric. Canvas (' Canvas ');
var rect = new fabric. Rect ({
TOP:50,
LEFT:100,
WIDTH:100,
Height:70,
Fill: ' Red '
});
Canvas.add (rect);
}
</script>
<body>
<canvas id= "Canvas" width= "height=" ></canvas>
</body>