rgba
does take values in a 0-100 range, where 100 corresponds to 100%. However it is not limited to this range - you can pass 255, but that corresponds to 255% red, as in 2.5x more red than you'd normally get. This may be why you are getting unexpected results when passing 255 to rgba
: it works, but not like you are expecting it to.
If you want to use a 0-255 range, then there is rgba255
and rgbex255
, which work identically but take values in a 0-255 range, where 255 corresponds to 100%. Again you can pass higher values like 500, but that corresponds to boosting that channel to higher than 100%.