# fabric.js **Repository Path**: mirrors_leecade/fabric.js ## Basic Information - **Project Name**: fabric.js - **Description**: Fabric.js — Object Model for HTML5 Canvas + SVG-to-Canvas (& canvas-to-SVG) Parser. - **Primary Language**: Unknown - **License**: MIT-0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-09 - **Last Updated**: 2026-02-07 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ### Fabric [![Build Status](https://secure.travis-ci.org/kangax/fabric.js.png?branch=master)](http://travis-ci.org/#!/kangax/fabric.js) **Fabric.js** is a framework that makes it easy to work with HTML5 canvas element. It is an **interactive object model** on top of canvas element. It is also an **SVG-to-canvas parser**. Using Fabric.js, you can create and populate objects on canvas; objects like simple geometrical shapes — rectangles, circles, ellipses, polygons, or more complex shapes consisting of hundreds or thousands of simple paths. You can then scale, move, and rotate these objects with the mouse; modify their properties — color, transparency, z-index, etc. You can also manipulate these objects altogether — grouping them with a simple mouse selection. Contributions are very much welcome! ### Goals - Unit tested (1300+ tests at the moment) - Modular (~20 small "classes" and modules) - Cross-browser - [Fast](https://github.com/kangax/fabric.js/wiki/Focus-on-speed) - Encapsulated in one object - No browser sniffing for critical functionality - Runs under ES5 strict mode - Runs on a server under [Node.js](http://nodejs.org/) ### Supported browsers - Firefox 2+ - Safari 3+ - Opera 9.64+ - Chrome (all versions should work) - IE9+ #### With help of [Explorer Canvas](http://code.google.com/p/explorercanvas/) - IE8 (incomplete — about 17 failing tests at the moment) - IE7,6 (incomplete - about 27 failing tests at the moment) You can [run automated unit tests](http://kangax.github.com/fabric.js/test/unit/) right in the browser. ### History Fabric.js started as a foundation for design editor on [printio.ru](http://printio.ru) — interactive online store with ability to create your own designs. The idea was to create [Javascript-based editor](http://printio.ru/ringer_man_tees/new), which would make it easy to manipulate vector shapes and images on T-Shirts. Since performance was one of the most critical requirements, we chose canvas over SVG. While SVG is excellent with static shapes, it's not as performant as canvas when it comes to dynamic manipulation of objects (movement, scaling, rotation, etc.). Fabric.js was heavily inspired by [Ernest Delgado's canvas experiment](http://www.ernestdelgado.com/public-tests/canvasphoto/demo/canvas.html). In fact, code from Ernest's experiment was the foundation of an entire framework. Later, Fabric.js grew into a collection of distinct object types and got an SVG-to-canvas parser.

Building

1. [Install Node.js](https://github.com/joyent/node/wiki/Installation) 2. Build distribution file **[~76K minified, ~22K gzipped]** $ node build.js - Or build a custom distribution file, by passing (comma separated) module names to be included.
$ node build.js modules=text,serialization,parser // or $ node build.js modules=text // or $ node build.js modules=parser,text // etc. By default (when none of the modules are specified) only basic functionality is included. See the list of modules below for more information on each one of them. Note that default distribution has support for **static canvases** only. To get minimal distribution with interactivity, make sure to include corresponding module: $ node build.js modules=interaction - You can also include all modules like so: $ node build.js modules=ALL 3. Create a minified distribution file # Using YUICompressor (default option) $ node build.js modules=... minifier=yui # or Google Closure Compiler $ node build.js modules=... minifier=closure 4. Optionally, you can build documentation $ node build_docs.js ### Demos - [Demos](http://fabricjs.com/demos/) - [Kitchensink demo](http://fabricjs.com/kitchensink/) - [Benchmarks](http://fabricjs.com/benchmarks/) ### Documentation Documentation is always available at [http://fabricjs.com/docs/](http://fabricjs.com/docs/). You can also build it locally, following step 4 from the "Building" section of this README. Also see [presentation from BK.js](http://www.slideshare.net/kangax/fabricjs-building-acanvaslibrarybk) and [presentation from Falsy Values](http://www.slideshare.net/kangax/fabric-falsy-values-8067834) for an overview of fabric.js, how it works, and its features. ### Optional modules These are the optional modules that could be specified for inclusion, when building custom version of fabric: - **text** — Adds support for `fabric.Text` - **serialization** — Adds support for `loadFromJSON`, `loadFromDatalessJSON`, and `clone` methods on `fabric.Canvas` - **interaction** — Adds support for interactive features of fabric — selecting/transforming objects/groups via mouse/touch devices. - **parser** — Adds support for `fabric.parseSVGDocument`, `fabric.loadSVGFromURL`, and `fabric.loadSVGFromString` - **image_filters** — Adds support for image filters, such as grayscale of white removal. - **easing** - Adds support for animation easing functions - **node** — Adds support for running fabric under node.js, with help of [jsdom](https://github.com/tmpvar/jsdom) and [node-canvas](https://github.com/learnboost/node-canvas) libraries. ### Examples of use #### Adding red rectangle to canvas ... var canvas = new fabric.Canvas('canvas'); var rect = new fabric.Rect({ top: 100, left: 100, width: 60, height: 70, fill: 'red' }); canvas.add(rect); ### Staying in touch Follow [@fabric.js](http://twitter.com/fabricjs) or [@kangax](http://twitter.com/kangax) on twitter. Questions, suggestions — [fabric.js on Google Groups](http://groups.google.com/group/fabricjs). ### Credits - Ernest Delgado for the original idea of [manipulating images on canvas](http://www.ernestdelgado.com/archive/canvas/). - [Maxim "hakunin" Chernyak](http://twitter.com/hakunin) for ideas, and help with various parts of the library throughout its life. - [Sergey Nisnevich](http://nisnya.com) for help with geometry logic. - Github contributors: @Kingsquare, @cleercode, @jarek-itmore, @sunrei, @khronnuz, @ollym, @Kienz, @willmcneilly, @davidjrice ### MIT License Copyright (c) 2008-2012 Printio (Juriy Zaytsev, Maxim Chernyak) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.