Different systems have different ways to describe colors, even if all of them are speaking in R-G-B-A space. A front-end developer who is familiar with CSS may prefer #RRGGBBAA
. But Android developers may prefer #AARRGGBB
. When handling AAS file format, #AABBGGRR
is needed. That's too confusing. Maybe we need a program which can convert between different color formats.
Input:
The input contains 3 parts:
- The color to be transformed (e.g.
#1459AC0F
), a string starting with sharp sign#
followed by 8 hex digits. - The format of the given color (e.g.
#RRGGBBAA
), a string starting with#
followed by 8 letters which fall into 4 different groups and each group is one ofRR
/GG
/BB
/AA
. - The format to convert to.
Output:
- Output the color in converted format
Test Cases:
Color, OriginalFormat, TargetFormat -> Result
#12345678, #RRGGBBAA, #AARRGGBB -> #78123456
#1A2B3C4D, #RRGGBBAA, #AABBGGRR -> #4D3C2B1A
#DEADBEEF, #AARRGGBB, #GGBBAARR -> #BEEFDEAD
Input / output are case insensitive. You may input / output in any acceptable way.
Rules:
This is code golf, shortest (in byte) codes of each language win
AARRGGBB
is objectively the best color format. If something expects 24 bitRRGGBB
and you give it 32 bitAARRGGBB
instead, it can just ignore the upper byte and still work. \$\endgroup\$