How to configure Fabric.js?

I just started learning how to use fabric.js and I find very few resources on how to install it on my site. All I can find is one stack overflow issue, which refers to the file "all.min.js", which no longer exists when quickly searching for an unpacked file.

I have tried the internet for the past few hours, and it looks like this is common knowledge! I'm still stuck.

Which file should I link in my HTML?

Edit: just for clarification, I downloaded a large ZIP file from fabric.js github. I was confused as to which file I should connect to in order to enable the library.

+6
source share
2 answers

The fabric follows a fairly traditional distribution.

You want to use the files from the dist directory. fabric.js for development and fabric.min.js for a live site.

+4
source

All you have to do is download the fabric.js file from HERE and save it as a js file called fabric.js , and create the html file, assuming index.html , with the contents below.

To run this example, these fabric.js and index.html must be in the same folder.

 <html> <head> <script src="fabric.js"></script> </head> <body> <canvas id="canvas" width="800" height="450" style="border:1px solid #000000"></canvas> <script> var canvas = new fabric.Canvas('canvas'); canvas.add(new fabric.Circle({ radius: 30, fill: '#f55', top: 100, left: 100 })); canvas.selectionColor = 'rgba(0,255,0,0.3)'; canvas.selectionBorderColor = 'red'; canvas.selectionLineWidth = 5; </script> </body> </html> 

Option

You can download fabric.js in any format from HERE

+7
source

Source: https://habr.com/ru/post/974272/


All Articles