konvajs / konva

Konva.js is an HTML5 Canvas JavaScript framework that extends the 2d context by enabling canvas interactivity for desktop and mobile applications.
http://konvajs.org/
Other
11.59k stars 926 forks source link

should clear context in the begin of sceneFunc? #155

Closed polokobe closed 8 years ago

polokobe commented 8 years ago

Hi, when I setAttrs() a shape, the new style of context does not display in the right way. should clear context in the begin of sceneFunc?

lavrton commented 8 years ago

@polokobe can you provide any examples? You may take a look into this example: http://konvajs.github.io/docs/shapes/Custom.html Also, are you calling layer.draw() after setting attrs?

polokobe commented 8 years ago

My code is :

shape.sceneFunc(function(context) {
    // I do this to clear canvas
    context.clearRect(0, 0, context.canvas.width, context.canvas.height);
    context.beginPath();
    ........
}

when I use setAttrs(), I must do that to clear the canvas. And in the source code of konvajs,

 drawScene: function(can, top, caching, skipBuffer) {
     ....
}  

It seems that there is no code to do that. Thanks!

lavrton commented 8 years ago

@polokobe you do not need to clear canvas. Konva will do it for you.

lavrton commented 8 years ago

I will close this issue. You can reopen it if you still have questions.