This uses grDevices::col2rgb() to handle standard R colours (like 'red') and also hex colours like '#123456ff'

sanitise_colour_to_rgba_vec(colour)

Arguments

colour

specified as hex-colour (e.g. '#123456'), standard colour name (e.g. 'red'), 3-element RGB vector (alpha will be assumed to be 255), or 4-element RGB vector

Value

4 element vector representing RGBA with each element in range [0, 1]

Details

When colour supplied as a vector, elements must in range [0, 255]