mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-04-15 20:01:00 +00:00
Javascript Canvas Library, SVG-to-Canvas (& canvas-to-SVG) Parser
| dist | ||
| lib | ||
| src | ||
| test | ||
| fabric.js | ||
| LICENSE | ||
| README.md | ||
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.
Goals
- Unit tested (~925 tests at the moment)
- Modular
- Cross-browser
- Fast
- Encapsulated in one object
- No browser sniffing for critical functionality
Supported browsers
- Firefox 2+
- Safari 3+
- Opera 9.64+
- Chrome 1+
Building
-
Install Sprockets
$ gem install --remote sprockets -
Build distribution file
$ sprocketize fabric.js > dist/all.js -
Create a minified distribution file
$ java -jar lib/yuicompressor-2.4.2.jar dist/all.js -o dist/all.min.js
Examples of use
Adding red rectangle to canvas
<canvas id="canvas" width="300" height="300"></canvas>
...
var canvas = new fabric.Element('canvas');
var rect = new fabric.Rect({
top: 100,
left: 100,
width: 60,
height: 70,
fill: 'red'
});
canvas.add(rect);
Object Model hierarchy
fabric.Object
|
-- fabric.Line
|
-- fabric.Circle
|
-- fabric.Ellipse
|
-- fabric.Rect
|
-- fabric.Polyline
|
-- fabric.Polygon
|
-- fabric.Group
|
-- fabric.Text
|
-- fabric.Image
|
-- fabric.Path
|
-- fabric.PathGroup
fabric.util
|
-- removeFromArray
|
-- degreesToRadians
|
-- toFixed
|
-- getRandomInt
Canvas
|
-- parseAttributes
|
-- parseElements
|
-- parseStyleAttribute
|
-- parsePointsAttribute
fabric.Element
fabric.Point
fabric.Intersection
fabric.Color
Credits
- Ernest Delgado for the original idea of manipulating images on canvas.
- Maxim "hakunin" Chernyak for ideas, and help with various parts of the library.
- Sergey Nisnevich for help with geometry logic.
License
MIT License
TODO
- Write unit tests for fabric.base.* and move them to fabric.util.*