nacnudus/tidyxl

Add functions to convert ARGB to RGBA in hex and decimal

Closed this issue · 4 comments

oganm commented

The documentation of the xlsx_cells function seem to suggest we can use rgb function to convert rgb values to hex strings but rgb function returns values in RGBA format, having the alpha channel at the end while the output of xlsx_cells seems to be ARGB, with alpha channel at the front.

Not sure if which form of output is the original intention but it calls for a change in either the documentation or functionality

I agree, this is a pain. ARGB is consistent with Excel. I'll think about adding functions to convert them.

Just realised that it's easy to rgb() to create an ARGB string, by giving it the A R G B values in that order.

A <- 1; R <- 0.5; G <- 0; B <- 0
rgb(A, R, G, B)
# [1] "#FF800000"
```
I'll add this trick to the documentation.

Closed by 6947115. Please reopen if you would like something else.

oganm commented

That's nice and simple. Though for people who like to name their arguments and not get confused maybe you can include

argb = function(r, g, b, a, ...){
    rgb(a,r,g,b, ...)
}

or

argb = function(a, r, g, b, ...){
    rgb(a, r, g, b, ...)
}