0.3.3 • Published 6 years ago
fabric-canvas v0.3.3
<fabric-canvas>
<fabric-canvas> is a Web Component wrapper for the popular javascript library fabric.js.
- Declarative API
- Responsive canvas size
- fabric.js ES module
Live demo ↗ | API documentation ↗

Installation
Install fabric-canvas:
npm i fabric-canvas --saveUsage
Import the web component in your application:
import 'fabric-canvas';Or import the static version:
import 'fabric-canvas/src/fabric-static-canvas';In order to use the fabric API to create shapes, you must import the fabric module along with the web component:
import { fabric } from 'fabric-canvas';Add the <fabric-canvas> element to the page:
<fabric-canvas></fabric-canvas>Adding Shapes
JS API
const rect = new fabric.Rect({
top: 100,
left: 100,
width: 200,
height: 200,
fill: 'red'
});
document.querySelector('fabric-canvas').add(rect);HTML API
<fabric-canvas>
<fabric-rect top="100" left="100" width="200" height="200" fill="red"></fabric-rect>
</fabric-canvas>Running demo
Fork the
fabric-canvasrepository and clone it locally.Make sure you have npm installed.
When in the
fabric-canvasdirectory, runnpm installto install dependencies.Run
npm startto open the demo.
License
This project is licensed under the MIT License.