如何设置Fabric.js? [英] How to setup the Fabric.js?

查看:129
本文介绍了如何设置Fabric.js?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对fabric.js非常陌生.我已经下载了fabric.js,但是我不知道如何启动它.例如:

I am very new to fabric.js. I have downloaded the fabric.js, but I don't know how to start it. For example:

<html>
<head>
    <script src="fabric.min.js"></script>
</head>

<body>
    <canvas id="canvas" width="800" height="450" style="border:1px solid #000000"></canvas>
    <script>
        var canvas = new fabric.Canvas('c1');
        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>

在此脚本中,我应该看到一个圆圈.我遵循以下示例: http://fabricjs.com/customization/

In this script I supposed to see a circle. I followed this example: http://fabricjs.com/customization/

但是为什么我什么都看不到;我想念的是什么?

But why I couldn't see anything; what I am missing?

推荐答案

fabric.Canvas的参数应与html中的canvas ID匹配.

The parameter of fabric.Canvas should match the canvas id in html.

更改行

var canvas = new fabric.Canvas('c1');

var canvas = new fabric.Canvas('canvas');

这应该有效.

这篇关于如何设置Fabric.js?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆