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:

  1. why rectangle doesn't draw on canvas when open saved html file?
  2. 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

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -