简体   繁体   中英

How to Totally clear the canvas using CamanJS

I am using CamanJS to create a photo editing app with filters. I have it working perfectly but after the user uploads an image then goes through the process of uploading another one as soon as they apply any filter it reverts the canvas back to the previously uploaded image. I am using the revert() function but I am also reassigning the canvas to the newly uploaded image but it still reverts back to the first image. So my question is, is there a way to totally clear the canvas/camanJS revert memory to the point where camanJS revert() will not revert to the previous image?

One of my filters:

function vintage(){
    Caman("#myFilterCanvas", function () {
        this.revert();
            this.greyscale();
        this.contrast(5);
        this.noise(3);
        this.sepia(100);
        this.channels({
          red: 8,
          blue: 2,
          green: 4
        });
        this.gamma(0.87);
        this.vignette("40%", 30);
        this.render();
});
}

Try with below,

                        this.revert(false);
                        this[effect]();
                        this.render();

or

Could you please share some code in JSfiddle.

try this code

this.reloadCanvasData();
this.revert(false);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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