문제

캔버스를 사용하여 다음과 같이 그리기 위해 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 ... 한 가지 더 : 케이크의 웹 사이트입니다.링크

도움이 되었습니까?

해결책

캔버스 제거 :

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