Jquery.eraser Picture Mask Mask Erase plugin usage

Source: Internet
Author: User

Jquery.eraser is a plugin that uses mouse or touch actions to erase images, this plugin replaces the target image with an interactive canvas that can be erased using touch or mouse input. You can specify a callback function to complete and set the brush size.

This effect is a little bit iOS above the eraser application, this plugin uses the image or canvas element but you have to make sure that the picture is loaded after full load call eraser (), otherwise it won't work, and I conclude that the following code runs in Safari,chrome OS x and Windows, Android and iOS Firefox, BlackBerry and other browsers.

How to use

To turn an image or canvas into a erasable canvas, just use this syntax:

$ (' #yourImage '). Eraser ();

Specify a brush size and add some options (the default is 40):

$ (' #yourImage '). Eraser ({size:30});
You can also change the size after:
$ (' #yourImage '). Eraser ("Size", 30});

You can reset the canvas (back to the original image) with this code:

$ (' #yourImage '). Eraser (' reset ');

You can call the contents of the Erase canvas:

$ (' #yourImage '). Eraser (' clear ');

To get a callback when image 50% has been removed, use this:

$ (' #yourImage '). Eraser ({
Completeratio:. 5,
Completefunction:showresetbutton
});

If you are need to manually query the progress of the user, use the progress method:

var progress = $ (' #yourImage '). Eraser (' progress '); Returns a value between 0 and 1
There is also a progressfunction option where can we provide a function that'll be called each time the user erases a n EW area. It receives as argument the normalized progress value (0.0 to 1.0).

$ (' #yourImage '). Eraser ({
Progressfunction:function (p) {
Console.log (Math.Round (p * 100) + '% ');
}
});

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.