【问题标题】:Kineticjs Complex Image ClippingKineticjs 复杂图像剪辑
【发布时间】:2014-11-26 04:10:47
【问题描述】:

我试图在 KineticJS 中模拟这个 other's Stackoverflow canvas clipping function 并具有可拖动图像的附加功能,但我无法完成。

小提琴:http://jsfiddle.net/dekaa/6L1wxt1g/

shape = new Kinetic.Shape({
    sceneFunc:function(ctx){
        ctx.drawImage(clipping_mask,0,0);
        ctx.globalCompositeOperation = "source-in";
        ctx.drawImage(main_image,0,0);
    },
    draggable:true
});

尝试使用sceneFunc 功能,当我使用它时,可拖动功能不起作用。那么问题是它可以在 KineticJS 中完成吗?

【问题讨论】:

    标签: javascript html kineticjs clip


    【解决方案1】:

    ctx 参数不是本地上下文。

        ctx.drawImage(clipping_mask,0,0);
        ctx.setAttr('globalCompositeOperation',"source-in");
        ctx.drawImage(main_image,0,0);
    

    http://jsfiddle.net/6L1wxt1g/1/

    【讨论】:

    • 啊,非常感谢,我忘了这个。 globalCompositeOperation 现在可以工作了,但是可拖动的仍然不能工作。
    • 非常感谢您的回答。现在说得差不多了。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-05-07
    • 2012-12-10
    • 2017-06-04
    • 2016-04-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多