-
Notifications
You must be signed in to change notification settings - Fork 9
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
Support for transparent images #6
Comments
Thanks for the work. I'll go over the details later when I recover from my cold T_T |
Any news? |
@stefandevo Consider migrating the proposed code changes to a pull request? |
Kinda busy recently. Will definitely look into this. |
@stefandevo your modification is indeed a very reasonable change. The only issue I'm thinking is for transparent images, revealing percentage could be a bit hard to define intuitively: Should we go for "total percentage revealed" or "extra percentage scratched on top of the original". And with some more experience in Vue, my original code now looks a bit entangled with anti-patterns in Vue SFC. I'll find a time to refactor it to a newer version and port your snippets in, but maybe not this version just yet (unless I see more pressing need for people using the feature), as I'm a bit wary of the layered complexity on top of the original spaghetti. In the meantime I'm open to suggestions on the specification of |
Ok, I implemented it in a fork for me as I needed this in production. My thought is, when you deliberate want to use transparent pixels to only overlay a portion of your image, then you would also count the percentage finished upon the total non-transparent pixels. |
Hmm... Makes sense, so will be "total revealed" then |
@stefandevo Do you have a link to the fork you created? I think I may be running into this issue as well. |
Related to #5
I changed the code a little bit to support transparent images too. Please check it out.
Basically, when assigned, I count the non-transparent pixels (for an image with transparent pixels this is import). Then when evaluating the reveal percentage, I count the non-transparent pixels again, and compare it to the original. That way you always have a correct percentage.
the new method:
the modified methods:
an extra data value must be added:
And a small bug, where you can now set 100 as reveal percentage as well:
With this you can now use a background image for the revealed image, and a image with transparent pixels but with a small part as the scratch area. Please find attached these two files as an example:
The text was updated successfully, but these errors were encountered: