javascript - How to start with fabric.js -
i beginner study js. encounter issue start fabric.js
needs help.
<!doctype html> <html> <head> <title>fabric_test</title> <script type="text/javascript" src="all.js"></script> </head> <body> <canvas id="canvas" width="512" height="512" style="background-color: rgb(222, 222, 222)"> browser not support canvas tag! </canvas> <script type="text/javascript"> var canvas = new fabric.canvas('canvas'); // create rectangle object var rect = new fabric.rect({ left: 100, top: 100, fill: 'red', width: 20, height: 20 }); // "add" rectangle onto canvas canvas.add(rect); </script> </body> </html>
my question is:
- why rectangle doesn't draw on canvas when open saved html file?
- the fabric download folder contains several folders , files. copy
all.js
file on current location. right?
this problem caused because put background in canvas object. so, color on inside elements. remove background style canvas.
Comments
Post a Comment