alpha handling

#1 · closed · 2 comments

View on GitHub ↗

alistaire47

Hi! I just started learning Processing for fun, and was thinking that once I got up to speed, I should build a package to make p5.js htmlwidgets, but a quick github search revealed you already had! And it's wonderful. While trying it out, I noticed that alpha doesn't behave as it should. According to [p5.js #2046](https://github.com/processing/p5.js/issues/2046), support for `#rrggbbaa` and `#rgba` specifications has already been added as of July, so the way to sort this may just be updating. Reprex: ``` r library(p5) fill_color <- rgb(1, 1, 1, alpha = .5) fill_color #> [1] "#FFFFFF80" p5() %>% background('#000') %>% fill('#00F') %>% rect(10, 10, 50, 50) %>% fill(fill_color) %>% rect(20, 20, 50, 50) ``` ![](https://i.imgur.com/iNvXEqV.png) For now, opacity can still be generated by specifying an `rgba` function as a string per [the docs](https://p5js.org/reference/#/p5/fill): ``` r p5() %>% background('#000') %>% fill('#00F') %>% rect(10, 10, 50, 50) %>% fill('rgba(255, 255, 255, 0.5)') %>% rect(20, 20, 50, 50) ``` ![](https://i.imgur.com/RGLOF7A.png) Really, the background should be bleeding through too, though that's clearly a p5.js issue.

Comments

seankross

Thank you for pointing this out and including a great reproducible with the desired behavior included. Fixing now...

alistaire47

Perfect, thanks!