Blend Mode For Draw & Erase

Blend Mode For Draw & Erase
0.0 0


I am developing a paint app. I want to make basic brush and erase. I tried blend mode drawNode.setBlendFunc(gl.ZERO,gl.ONE_MINUS_SRC_ALPHA); for eraser but it is not working. Are there anbody help me? İf there is anyway to develop eraser please tell me :relaxed:


check this out maybe it can Help:

erase.setBlendFunc(  cc.ZERO, cc.ONE_MINUS_SRC_ALPHA );

works for me.


Thanks for everyone. Joseph’s example is perfect :blush:


Any idea how to do this in Cocos Creator?

Looks like RenderTexture isn’t part of cocos creator.

currently I have this code in creator’s canvas onLoad Function…

It draws the brush fine and follows the touch movement, now if I can just get it to interact with a sprite to erase it’s pixels…

        var brush = new cc.Node('brush01');
        var sprite = brush.addComponent(cc.Sprite);
        sprite.spriteFrame = this.brush;
        sprite.srcBlendFactor = cc.BlendFunc.BlendFactor.ZERO;
        sprite.dstBlendFactor = cc.BlendFunc.BlendFactor.ONE_MINUS_SRC_ALPHA;
        brush.parent = this.node.parent;
        brush.setScale(0.1 ,0.1 );
        brush.opacity = 255;
        this.node.on(cc.Node.EventType.TOUCH_START, function (event) {
            //eraseAtPoint(event.getLocation(), brush);
        this.node.on(cc.Node.EventType.TOUCH_MOVE, function (event) {
            eraseAtPoint(event.getLocation(), brush);
        this.node.on(cc.Node.EventType.TOUCH_END, function (event) {
        var eraseAtPoint = function(pt,brush){


@slackmoehrle any idea?

I may just have to drop Cocos Creator and use standard Cocos2d-x api.


Let me ask someone to look at your question.


@slackmoehrle I’m guessing it’s not possible in cocos creator yet. Will just use Cocos2d-x CLI


I’m not sure and it is the weekend for the engineering team, so I’d assume they will answer this soon.


Alright I’ll look forward to hearing back from them. I’d like to use the latest iteration of cocos (‘cocos creator’) if possible.


Never heard back on this. I got it to work in cocos2d-x but not cocos creator… Any update on blend modes in cocos creator?


@slackmoehrleany update?


@nantas any thoughts?


Is there any way we can found the erase percentage? I mean how much texturein term of percenetage still remaining ?