Search code examples
jquerycanvasjcanvas

How to clear a single layer among a group of layers in jCanvas


I am using the latest version of jCanvas. I have two layers on my canvas. I have a function which draws those 2 layers. Everytime the function is called, I want to clear one layer and keep the other layer intact cause I'm plotting a curve on the latter. How do I clear a single layer using jCanvas? I could not find anything on clearing layers in the documentation of jCanvas.


Solution

  • Suggest you use the removeLayer() API. Here's the API doc, make sure you heed the part about calling drawLayers() after calling removeLayer().

    UPDATE 2013-02-16: Since jCanvas version 13.02.11, drawLayers() happens automatically after the user calls removeLayer(), so the explicit drawLayers() call by the user is no longer necessary. Also since the 2013-02-13 commits, there is unit test code in the "tests" subdirectory that demonstrates the new functionality.