HTML5 Canvas Drawing Library Introduction (Fabric.js)

Source: Internet
Author: User
Tags object model

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>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.