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

Support for other colors? #4

Open
agilgur5 opened this issue Sep 13, 2018 · 1 comment
Open

Support for other colors? #4

agilgur5 opened this issue Sep 13, 2018 · 1 comment

Comments

@agilgur5
Copy link
Owner

agilgur5 commented Sep 13, 2018

Potential downstream request from agilgur5/react-signature-canvas#22

The trimCanvas function would have to accept a second argument for the color and default to transparency detection. Since this hasn't really come up in 2 years and there are alternative ways to achieve the behavior wanted in that issue, I'm not sure that it's worth the added complexity, but I'll document my thoughts here.

In order to be backwards-compatible, the second argument would have to be able to accept wildcards, since right now the function only checks the RGBA alpha transparency if it's not 0 and doesn't even check any of the other RGB parts.

The backwards-compatible wildcard requirement also means one couldn't necessarily just use color-rgba to parse the second argument, unless the default behavior was just kept as different from the arg behavior (as there is no color equivalent to the current check of rgba(*,*,*,0)).

color-rgba is also much larger than this library so that would make an extremely significant size increase, clashing with the existing image of "tiny (< 100 LoC)". Could accept only 'rgba(r,g,b,a)' strings and do some manual parsing instead, but that wouldn't entirely fulfill the downstream issue as there backgroundColor accepts other types of color strings :/ . That would therefore either be incomplete or end up pushing the dependency downstream.

@agilgur5
Copy link
Owner Author

Re-read this since #10 was created which duplicates this, and I didn't seem to specify how to workaround this as I did downstream.

Per agilgur5/react-signature-canvas#22 (comment), you can use a background-color CSS style on your <canvas ... /> element to generally workaround this. If you need to set the actual color of the canvas though, then you can't simply workaround it this way, but I assume many use-cases can just be worked around like this via CSS instead.

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

No branches or pull requests

1 participant