displayio: Pass transparent_color to ColorConverter#3529
Conversation
9bb2d70 to
3e27b77
Compare
tannewt
left a comment
There was a problem hiding this comment.
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
tannewt
left a comment
There was a problem hiding this comment.
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. 👍 |
Signed-off-by: Jensen <jensechu@gmail.com>
630bed2 to
3370196
Compare
|
I am not sure why I got this single failure. 😅 |
tannewt
left a comment
There was a problem hiding this comment.
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. :) |
tannewt
left a comment
There was a problem hiding this comment.
One more tiny doc improvement. Otherwise it looks really good! Thanks!
Co-authored-by: Scott Shawcroft <scott@tannewt.org>
|
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.
tannewt
left a comment
There was a problem hiding this comment.
Thank you! Merging because the only failure is a known mac mpy-cross issue.
|
Thank you both! |
Signed-off-by: Jensen jensechu@gmail.com
Summary
Add the ability to pass in a color into the ColorConverter module so it flags a pixel as
opaque=falsewhich I think will make it use thebackgroundvalue (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_tdeclared in the types formp_arg_t. That seems expected because it might be weird anyone is passing in auint32_tvalue. My thought was perhaps to just make thetransparent_colorarg anintinstead and then convert it and move on to the comparison to theinput_pixelto 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. 😄