Layer Drawing layers 绘制层 - caleb531/jcanvas-docs GitHub Wiki

Drawing layers 绘制层

The drawLayers() method clears the canvas, and draws the canvas's layers.
drawLayers()方法会清空画布,并绘制画布上的层。

$('canvas').drawLayers();

The layers are drawn from first to last, so the last layer will be drawn above all the others.
层是从第一个绘制到最后一个,因此最后一个层会绘制在所有其它层之上。
However, if you need to draw only a single layer on the canvas (to accompany asynchronous code), then use the drawLayer() method.
但如果你需要在画布上绘制一个单独的层(伴随异步代码),那就要使用drawLayer()方法了。

这段话我在GITHUB上问作者了,他对这句话的解释是下边:
drawLayer() isn't as useful anymore because jCanvas handles more of that logic for you, but it used to be that if you had an image layer, you couldn't draw other layers until the image has been loaded and drawn. drawLayers() would allow you draw the successive layers conditionally in this manner. As I mentioned, I wouldn't advise using it though, as jCanvas now waits for images to load before drawing successive layers (this is really the only use case for drawLayers()).
drawLayer不再是很有用的方法,因为jCanvas会为你处理得更具有逻辑性,但如果你有图像层的话它就是有用的方法了。你没办法在图像调用并绘制之前,绘制其它层。drawLayers允许你在这种情况下有条件地绘制连续的层。像我说的那样,尽管我不建议使用它,因为jCanvas现在在绘制连续的层(这就是使用drawLayers的仅有的情况)之前会等待图像调用完成。(其实他说完之后,我还是不太懂,大概就是防止因为调用被卡住吧)

$('canvas').drawLayer(0);
$('canvas').drawLayer('myBox');

Please note that the drawLayer() method does not clear the canvas before drawing, unlike the drawLayers() method.
请注意,drawLayer()方法不会清除画布上之前画的内容,不像drawLayers()方法。


上边的是之前的文档,下边的是最新的,就一句话

The drawLayers() method clears the canvas, and draws the canvas’s layers.
drawLayers()方法会清空画布,然后绘制画布上的层。

$('canvas').drawLayers();