简体   繁体   English

同一画布上可以存在两个jcanvas图层蒙版吗?

[英]Can two jcanvas layer masks exist on the same canvas?

Is it possible to create two layer independent layer masks on the same canvas? 是否可以在同一画布上创建两个独立于图层的图层蒙版? I've tried, without much success. 我尝试过,但没有成功。 I suspect it's due to masks affecting layer indexes. 我怀疑这是由于遮罩影响图层索引。 I've highlighted this by enabling masking on mouseover ( see here ). 我通过在鼠标悬停时启用遮罩来突出显示这一点( 请参阅此处 )。 If you mouseover a layer mask, the other layer masks disappears. 如果将鼠标悬停在图层蒙版上,其他图层蒙版将消失。 If you draw the layer with mask:true as a property only one layer mask will appear. 如果使用mask:true作为属性绘制图层,则只会显示一个图层蒙版。 You might be thinking "why not make a separate canvas for each layer mask?" 您可能会想“为什么不为每个图层蒙版制作单独的画布?” I can't because I intend on using $("canvas").getCanvasImage(); 我不能,因为我打算使用$("canvas").getCanvasImage(); to render the canvas as a composite jpeg (which would be difficult with two canvases). 将画布渲染为复合jpeg(如果使用两个画布则很难)。

The end goal would be a canvas split vertically into two panes. 最终目标是将画布垂直分成两个窗格。 Each pane would be filled with an draggable image. 每个窗格将填充一个可拖动的图像。 Users would move the image in the pane to "crop" it and then render the result as a composite image. 用户将在窗格中移动图像以“裁剪”它,然后将结果呈现为合成图像。 This example comes close, but dragging the green box under the right pane creates a deadspace in that pane. 示例即将结束,但是将右窗格下的绿色框拖动到该窗格中会创建一个死区。

Thanks for you assistance. 感谢您的协助。

Yes, it's now possible with jCanvas. 是的,现在可以使用jCanvas。 Just be sure to call the restoreCanvas() method whenever you wish to restore a mask, like so: 只要确保要恢复遮罩,就一定要调用restoreCanvas()方法,如下所示:

$("canvas").restoreCanvas({
    layer: true
});

Here's an example I made which uses two masks to split the canvas into two panes. 这是我制作一个示例该示例使用两个蒙版将画布分成两个窗格。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM