nacnudus / tidyxl

Read untidy Excel files in R https://nacnudus.github.io/tidyxl/
https://nacnudus.github.io/tidyxl/
Other
248 stars 21 forks source link

Add functions to convert ARGB to RGBA in hex and decimal #49

Closed oganm closed 5 years ago

oganm commented 5 years ago

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

nacnudus commented 5 years ago

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

nacnudus commented 5 years ago

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.

nacnudus commented 5 years ago

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

oganm commented 5 years ago

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, ...)
}