Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-draw #5

Open
idan6189 opened this issue Dec 31, 2016 · 10 comments
Open

Re-draw #5

idan6189 opened this issue Dec 31, 2016 · 10 comments

Comments

@idan6189
Copy link

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

@sharish
Copy link
Owner

sharish commented Jan 10, 2017

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

@dondragon2
Copy link

When will this be added? This is most need feature

@ghost
Copy link

ghost commented Mar 27, 2018

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!!!

@varundwarkani
Copy link

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

@ghost
Copy link

ghost commented Jan 15, 2019

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!

@varundwarkani
Copy link

I tried the same but it wasn't working

@ghost
Copy link

ghost commented Jan 17, 2019

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

@sharish
Copy link
Owner

sharish commented Feb 18, 2019

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

@kashifansari786
Copy link

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

@rahat14
Copy link

rahat14 commented Oct 29, 2020

is the update available??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants