-
Notifications
You must be signed in to change notification settings - Fork 1.3k
displayio: Pass transparent_color to ColorConverter #3529
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
displayio: Pass transparent_color to ColorConverter #3529
Conversation
9bb2d70
to
3e27b77
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @jensechu! Instead of changing the constructor, how about adding make_transparent and make_opaque like Palette has? https://github.com/adafruit/circuitpython/blob/main/shared-bindings/displayio/Palette.c#L151-L179
We'll only be able to have one color at a time but then the API will be the same.
@tannewt Thanks for all of the feedback! I added in two methods.
I compiled everything and loaded it but I still see the pixels so I am hoping with your expertise you might be able to guide me to what the next step should be. 😄 I spent the better part of yesterday trying to figure out why but alas I was not able to. |
5c7418c
to
0a12cf3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I compiled everything and loaded it but I still see the pixels so I am hoping with your expertise you might be able to guide me to what the next step should be. smile I spent the better part of yesterday trying to figure out why but alas I was not able to.
Hrm, I thought it might be an issue with what calls the ColorConverter but the code looks right: https://github.com/adafruit/circuitpython/blob/main/shared-module/displayio/TileGrid.c#L439-L450
The next step I'd do is print out the two color values in ColorConverter when a color doesn't match the transparent one. (Printing when they do match will confirm it's working too.) I suspect it could be a component ordering issue where you are giving an RGB value but it's BGR internally.
9e2b414
to
630bed2
Compare
@tannewt Thanks for the review!! I am so close to finishing this up but alas I ran into an error when adding the exceptions. I keep running into:
I am going to try and figure out how to fix this now but it wasn't immediately clear to me. I still wanted to push the rest up nonetheless. I will also re-run make translate once this is done. 👍 |
630bed2
to
3370196
Compare
I am not sure why I got this single failure. 😅 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are some suggestions that should make it a bit smaller. Thanks!
…rcuitpython into color-converter-transparency
@tannewt Thank you again for all of your reviews. 😄 I initially kept the unused parameter but the linter was not happy with an unused parameter so I removed it. If you'd rather I use it superficially or something please let me know the best way and I can add it back in. Otherwise it is cleaned up. |
Also sorry my git history is a bit of a mess... I am happy to rebase and clean that up if needed. First time using the github UI to merge in suggestions. Not sure I will do that again haha. |
No problem! Thank you for improving things. :-) (We're working on the metro m0 size issue now separately as well.)
For unused parameters you can do
We're not sticklers on git history. Do whatever you'd prefer. |
2412fac
to
74c07a4
Compare
@tannewt 😱 They all passed. Please let me know if I should change anything else and I am happy to. :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more tiny doc improvement. Otherwise it looks really good! Thanks!
Co-authored-by: Scott Shawcroft <[email protected]>
I am cursed by this metro_m0_express board. 🤣 |
@jepler any ideas besides turning off the lto partitioning? |
This leads to smaller code size at the expense of slower linking. We can turn partitioning back on with GCC10 because it produces smaller code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Merging because the only failure is a known mac mpy-cross issue.
Thank you both! |
Signed-off-by: Jensen [email protected]
Summary
Add the ability to pass in a color into the ColorConverter module so it flags a pixel as
opaque=false
which I think will make it use thebackground
value (sub layer's pixel value) when rendering on the screen.Example:
displayio.ColorConverter(transparent_color=VALUEHERE)
I was unable to get this to compile so I couldn't test it as there is no type for an
uint32_t
declared in the types formp_arg_t
. That seems expected because it might be weird anyone is passing in auint32_t
value. My thought was perhaps to just make thetransparent_color
arg anint
instead and then convert it and move on to the comparison to theinput_pixel
to set it as not opaque.I decided to open this PR to know if my head is even in the right direction or maybe I should forego this approach. 😄