ScratchView icon indicating copy to clipboard operation
ScratchView copied to clipboard

Re-draw

Open idan6189 opened this issue 9 years ago • 10 comments

HI, How can i re-draw the scrachable layer?

idan6189 avatar Dec 31 '16 11:12 idan6189

Recreating scratch layer is not available in the current version. Thanks for the suggestion. Will include in the next version.

sharish avatar Jan 10 '17 14:01 sharish

When will this be added? This is most need feature

dondragon2 avatar Apr 06 '17 15:04 dondragon2

hi guys, I had to re-draw the scrachable layer. I override all class ScratchTextView and added this method:

public void repaint() {

       if (this.mDrawable != null && this.mGradientBgPaint != null && mScratchBitmap != null) {
           this.mScratchBitmap = Bitmap.createBitmap(this.getWidth(), this.getHeight(), Config.ARGB_8888);
           this.mCanvas = new Canvas(this.mScratchBitmap);
           Rect rect = new Rect(0, 0, this.mScratchBitmap.getWidth(), this.mScratchBitmap.getHeight());
           this.mDrawable.setBounds(rect);
           int startGradientColor = ContextCompat.getColor(this.getContext(), color.scratch_start_gradient);
           int endGradientColor = ContextCompat.getColor(this.getContext(), color.scratch_end_gradient);
           this.mGradientBgPaint.setShader(new LinearGradient(0.0F, 0.0F, 0.0F, (float) this.getHeight(), startGradientColor, endGradientColor, TileMode.MIRROR));
           this.mCanvas.drawRect(rect, this.mGradientBgPaint);
           this.mDrawable.draw(this.mCanvas);

           this.invalidate();
       }
   }

that's work for me.

Please add this code and update de library Thanks!!!

ghost avatar Mar 27 '18 19:03 ghost

How do you validate the onReveal listener again after repaint is done?

varundwarkani avatar Jan 15 '19 20:01 varundwarkani

How do you validate the onReveal listener again after repaint is done? In my case,

I create a listener on variables like this: kotlin code: var event = onRevealListener(.........

when you use repaint method... view.repaint(.... view.setOnReveal( event)...

the same for onclickEvent..

good luck!

ghost avatar Jan 15 '19 22:01 ghost

I tried the same but it wasn't working

varundwarkani avatar Jan 17 '19 05:01 varundwarkani

visit https://github.com/gtmora200/ScratchView I cloned and changed the code. Look the examples, my code is on: others examples -> Game Lotto.

image

image

ghost avatar Jan 17 '19 18:01 ghost

Ability to redraw, reveal fully and change image will be added soon. Apologies for the delay

sharish avatar Feb 18 '19 15:02 sharish

Ability to redraw, reveal fully and change image will be added soon. Apologies for the delay

can you tell me when this update is available. Thanks for this nice library

kashifansari786 avatar Jun 23 '19 08:06 kashifansari786

is the update available??

rahat14 avatar Oct 29 '20 09:10 rahat14