jQuery plugin that makes an image erasable (with mouse or touch movements)

Overview

jQuery.eraser v0.5.2

a jQuery plugin that makes an image erasable (with mouse or touch movements)

This plugin replaces the targeted image by an interactive canvas that can be erased using touch or mouse inputs. You can specify a callback for completion and set the brush size.

Please note that I don't claim that the completion detection process is ultimately accurate. In fact you should rather use a completeRatio around 0.8 if you want a near-complete erase process.

What's new in 0.5.2

Added the 'enable/disable/enabled' methods (see details in the Usage section)

What's new in 0.5.1

Added a 'progress' method (see details in the Usage section)

What was new in 0.5.0

Eraser now takes care of checking if the target image is already loaded. If not, it registers a callback on the load event and waits for the bitmap data to be available.

You don't have to worry anymore about anything but erasing.

Usage :

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

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

To specify a brush size, add some options (default value is 40) :

$('#yourImage').eraser( { size: 30 } );
// and you can also change the size later :
// $('#yourImage').eraser( 'size', 30 } );

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

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

And you can erase all the canvas' content by calling :

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

You can change whether erasing is enabled or disabled by calling the enable or disable methods :

$('#yourImage').eraser('enable');
$('#yourImage').eraser('disable');

And you can check whether erasing is enabled or disabled by calling :

$('#yourImage').eraser('enabled');

To get a callback when 50% of the image has been erased, use the following options :

$('#yourImage').eraser( {
	completeRatio: .5,
	completeFunction: showResetButton
});

If you 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 you can provide a function that will be called each time the user erases a new 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) + '%');
	}
});

URLs :

* https://github.com/boblemarin/jQuery.eraser
* http://minimal.be/lab/jQuery.eraser/

Created by @boblemarin

Comments
  • Callback after percentage complete

    Callback after percentage complete

    I have been trying to get this to work for a while the way you describe in your instructions, but after further investigation, I am finding that there is absolutely no reference to "completeRatio" or "completeFunction" in the jQuery.eraser code.

    Was something accidentally omitted in the commit?

    opened by ktch 6
  • Coordinates are lost inside a div with scroll bar.

    Coordinates are lost inside a div with scroll bar.

    Hi I am trying to make a game for children , they need to discover images behind other images. But I have the canvas inside others div with scroll bars.

    When you scroll down the coordinates of the brush are lost. Here an example:

    http://jsfiddle.net/L0oaar7z/

    Any idea of how to resolve this ?

    opened by SaulBurgos 3
  • How can i check how much area of iamge is erased ?

    How can i check how much area of iamge is erased ?

    I using this tool in a project. It is working wonderfull. I have one request to check how much area of image is calculated at moment . I will really appreciate your help.

    opened by mohitharrak 2
  • Callback function

    Callback function

    Hi

    Firstable I would like to say thanks for this great plugin. Everything works perfectly for my purpose and it does seems like the besteraser (scratch)plugin available online.

    I have been trying to get the callback function working.

    however the function is called when the document is loaded. ( instead of being calledback when the eraser function complete).

    function test() { $('#test').fadeIn(); } function init(event) { $("#redux").eraser({ completeRatio: 0.8, completeFunction: test() }); } addEventListener( "load", init, false );

    opened by shawnier 2
  • Fix broken headings in Markdown files

    Fix broken headings in Markdown files

    GitHub changed the way Markdown headings are parsed, so this change fixes it.

    See bryant1410/readmesfix for more information.

    Tackles bryant1410/readmesfix#1

    opened by bryant1410 1
  • it's not an issue it's a solution

    it's not an issue it's a solution

    In line 98 do this: ctx.drawImage(that, 0, 0, width, height); and in line 326 this: data.ctx.drawImage( data.source, 0, 0 , data.w, data.h);

    fix an issue in devices whith other devicePixelRatio but 1 (like he new iPad)

    Ok, i'm gonna write this in spanish, just because my shitty english: En la lína 98 pega esto:ctx.drawImage(that, 0, 0, width, height); y en la línea 326 esto: data.ctx.drawImage( data.source, 0, 0 , data.w, data.h);

    Arregla un problema en los dispositivos que tienen un devicePixelRatio distinto de 1 (como el nuevo iPad)

    opened by Landaes 1
  • android default browser erase issue

    android default browser erase issue

    HI,

    First of all - great script, does exactly what I was looking for.

    I have noticed in default android browser (tested with samsung s3 & galaxy tab running android 4.1.1- 4.2) the erase function doesn't work as expected.

    I have hooked up a callback (which fires) but the panel doesn't erase. Works fine in Chrome for android.

    Any idea why this is happening?

    opened by RandevM 1
  • evaluatePoint计算完成度问题

    evaluatePoint计算完成度问题

    evaluatePoint 函数中var p = Math.floor(tx / data.size) + Math.floor(ty / data.size) * data.colParts;是否应该改成var row=Math.ceil(ty / data.size)-1;row=(row<0)?0:row;var p = Math.floor(tx / data.size) +row * data.colParts;

    opened by EthanZhong 0
  • Fix for HiDPI devices.

    Fix for HiDPI devices.

    Images in canvas becomes blurry on HiDPI devices such as iPhone 5s, this patch fixes this problem. See also: http://www.html5rocks.com/en/tutorials/canvas/hidpi/

    opened by fantix 0
  • Eraser not working instantaneously on desktop browser (chrome or safari), have to resize browser window to make it work?

    Eraser not working instantaneously on desktop browser (chrome or safari), have to resize browser window to make it work?

    Hello,

    First of all, thanks a lot for this great plugin.

    It's working perfectly on mobile, but on desktop browser (chrome or safari), I have a minor issue I can't fix :

    1. It doesn't work by default, eraser seems to be blocked, impossible to erase the canvas
    2. If I resize the browser window, then it works: I can erase my canvas (which is a car in this example)

    See video of issue here: https://app.usebubbles.com/qgE8TyBph6PshyrD8NxJQc/comments-on-newtab/

    Thanks a lot in advance for your help!

    image

    opened by lmwebagency 0
  • How to replace the cursor?

    How to replace the cursor?

    I tried to change the cursor. So, I used some CSS to do it. But I was unable to achieve it.

    #redux {
        cursor: url("assets/img/brush.png"), url("assets/img/brush.cur"), default;
    }
    

    Could you add this as a feature? That would be so great if it is possible.

    opened by panatapattu 0
  • progress changes everytime I finish brush whole img

    progress changes everytime I finish brush whole img

    everytime I finish brush the whole image, the progress is different, sometimes 93%, sometimes 97%, and never 100%. Seems if I buttonup more times, the final progress will be higher, if I click down and drag a lot and not release the button, the progress will be lower. how this happen and can you help to fix, I'd like to have a 100% progress, thanks

    opened by echnyee 2
  • Hidden Div cannot work

    Hidden Div cannot work

    I have a hidden element. eraser cannot get the offset value. Then in MouseDown event I add these codes

        if (data.posX == 0) {
            data.posX = $this.offset().left;
            data.posY = $this.offset().top;
        }
    

    can fix this bug

    opened by vi000246 0
  • Unable to erase image on a bootstrap modal pop up

    Unable to erase image on a bootstrap modal pop up

    Hi, I have a requirement where i need to pop up the selected image and load eraser functionality to it. When i associated the eraser plugin to the image on the modal pop up it is not enabling the eraser functionality.

    Please guide me on how to achieve this.

    opened by sbojanapalli 0
Unite Gallery - Responsive jQuery Image and Video Gallery Plugin. Aim to be the best gallery on the web on it's kind. See demo here:

##Unite Gallery - Responsive jQuery Gallery Plugin Product Link: unitegallery.net This gallery has commercial versions for: WordPress , Joomla! , Pres

Max Valiano 531 Oct 24, 2022
jQuery plugin for 'responsive cropping'. Dynamically crop images to fill available space without cutting out the image's subject. Great for full-screen images.

jQuery plugin for 'responsive cropping'. Dynamically crop images to fill available space without cutting out the image's subject. Great for full-screen images.

Jono Menz 3.2k Dec 30, 2022
Nivo Slider - The Most Awesome jQuery Image Slider

Maintainer's Wanted! - Ineterested in contributing regularly to Nivo Slider development? Get in touch Nivo Slider The Nivo Slider is world renowned as

Verti Studio 1.2k Dec 24, 2022
A light wight javascript image viewing plugin with smooth animation and 0 dependence

A light wight javascript image viewing plugin with smooth animation and 0 dependence

null 50 Nov 12, 2022
jQuery plugin that blows your visitors' retinas

Dense.js Homepage | Issues | Dense is a jQuery plugin for serving retina-ready, high pixel ratio images with ease. Small, ease-to-adapt, yet very cust

Jukka Svahn 212 Jun 30, 2022
A jQuery plugin that displays a thumbnail grid expanding preview similar to the effect seen on Google Images.

jQuery GRIDDER 1.4.2 ======= A jQuery plugin that displays a thumbnail grid expanding preview similar to the effect seen on Google Images. We have all

Orion Gunning 455 Nov 6, 2022
jQuery plugin based on raphael.js that allows you to display dynamic vector maps

jQuery Mapael - Dynamic vector maps The complete documentation is available on Mapael website (repository: 'neveldo/mapael-documentation'). Additional

Vincent Brouté 1k Jan 5, 2023
A jquery plugin for comparing two images

jQuery Images Compare A jquery plugin for comparing two images Badges Features compatibility : ie9+ Effort to put appearance via css (easier to skin /

Sylvain Combes 49 Sep 5, 2022
:woman: Library for image processing

Lena.js Tiny library for image processing. Install via NPM npm install lena.js --save Install via yarn yarn add lena.js Run demo yarn demo Demo htt

Davidson Fellipe 558 Dec 28, 2022
Resize image in browser with high quality and high speed

pica - high quality image resize in browser Resize images in browser without pixelation and reasonably fast. Autoselect the best of available technolo

Nodeca 3.2k Dec 27, 2022
🌅 Content-aware image resizer based on Seam Carving algorithm

Content-aware image resizing might be applied when it comes to changing the image proportions (i.e. reducing the width while keeping the height) and when losing some parts of the image is not desirable.

Oleksii Trekhleb 1.4k Dec 30, 2022
ASP.NET Core image gallery with Marten, ImageSharp, and HTMX

Image Gallery This sample uses the following core technologies to deliver an image gallery experience: ASP.NET Core Marten ImageSharp.Web HTMX This al

Khalid Abuhakmeh 11 Feb 9, 2022
Get the first frame of a Gif image.

Get the first frame of a Gif image.

lijialiang 3 Apr 8, 2022
An image post-processing code library

WebGPU image filter Preview online 这是一个用来展示 webgpu 在图片处理方面应用的 demo,但由于 webgpu API 还不稳定,本地都需要经常修改 API 才能跟上金丝雀的脚步,所以本项目的效果目前也还不稳定,目前仅供学习交流。

kuake 4 Mar 8, 2022
A very barebones editor that supports clicking on any pixel in a JPEG image to see the 64 DCT coefficients that make up that 8x8 block

JPEG Sandbox This is a very barebones editor that supports clicking on any pixel in a JPEG image to see the 64 DCT coefficients that make up that 8x8

Omar Shehata 383 Jan 2, 2023
Doblar - a fully local image converter that runs in your browser

Doblar is a fully local image converter that runs in your browser. Doblar is purely client side: nothing is uploaded to a server or anything like that. All conversions take place in your browser, which means your files never leave your computer.

Armaan A 28 Dec 17, 2022
A simple image diff tool powered by avernakis.

Image Diff English | 简体中文 Introduction This is the tutorial project of Avernakis UI. Tiny, but production ready. Install Use npm as nam! (Node App Man

null 45 Dec 3, 2022
⚠️ [Deprecated] No longer maintained, please use https://github.com/fengyuanchen/jquery-cropper

Cropper A simple jQuery image cropping plugin. As of v4.0.0, the core code of Cropper is replaced with Cropper.js. Demo Cropper.js - JavaScript image

Fengyuan Chen 7.8k Dec 27, 2022
DEPRECATED jQuery Responsive Carousel.

YEAH SO THIS IS PRETTY MUCH DEAD, DO YOURSELF A FAVOR AND SWITCH TO tiny-slider Owl Carousel 2 Touch enabled jQuery plugin that lets you create a beau

null 7.7k Jan 4, 2023