I came across the invert()
function in CSS, which inverts the colors from the color space of the image. It takes an input of a value either in percentage, e.g. invert(60%)
, or number (0 through 1 inclusive), e.g. invert(.6)
, and inverts the image colors according to the input.
Then I came across this site which has several examples of using the invert()
function
https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/invert
I understand the working of the invert
function when input is 1 or 100% but I can't understand the working of invert(50%)
as it completely turns the image into grey.
I assumed the formula would be something like :
abs(255 - value of each pixel's individual channel value)
Changing the 255 into 128 doesn't work for turning the image completely to grey?
So I am unable to find the formula that is used to calculate the inverted values.