我可以制作一个obj来使用画布来绘制:

MyObj.myDiv = new Canvas($("effectDiv"), Setting.width,  Setting.height);

然后,我用它在画布上绘制一个矩形:

    var c =  new Rectangle(80, 80,
        {
            fill: [220, 40, 90]
        }
    );
    var move = new Timeline;
    move.addKeyframe(0,
        {
            x: 0,
            y: 0
        }
    );
    c.addTimeline(move);
    MyObj.myDiv.append(c);

但在绘制矩形之后,我想清除画布,但我不知道哪种方法以及如何做到这一点......

O ......还有一件事: 这是CAKE的网站: 链接

有帮助吗?

解决方案

清除画布:

canvas.clear = true; // makes the canvas clear itself on every frame
canvas.fill = somecolor; // fills the canvas with some color on every frame
// with canvas.clear = false and low-opacity fill, fancy motion blur effect

Removing the rectangle from the canvas:
rectangle.removeSelf();
or
canvas.removeChild(rectangle);

其他提示

您可以尝试以下方法:

MyObj.myDiv.clearRect(0, 0, canvas.width, canvas.height);

有效地为背景颜色整个画布着色。

最简单的方法是:

MyObj.myDiv.width = MyObj.myDiv.width;

我发现即使你没有真正改变尺寸,调整画布的大小就像魔术一样:

canvas.width = canvas.width
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top