Let say I have some element with background and foreground colors.
Let say there could be both colors specified in different formats (any that could be specified in style attribute) like background = ‘white’ or ‘transparent’, foreground = ‘rgb(0, 0, 0)’.
What is simplest way to merge these colors using pure javascript to get result like rgb(128, 128, 128)?
Thanks.
I believe setting
opacityCSS attribute to half (0.5) of the element on the front will get you there.Alternatively, if you are using jQuery and you really want to get this into JavaScript, you can get both colors with jQuery’s .css(), which returns something like
rgb(0,0,0), then make averages of each base color (red, green, blue) and set the resulting value to whatever you need with the same directive (.css()).Did it help?