You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to the w3c on luminance, luminance gets calculated differently to Spectra's current implementation.
the relative brightness of any point in a colorspace, normalized to 0 for darkest black and 1 for lightest white
Note 1: For the sRGB colorspace, the relative luminance of a color is defined as L = 0.2126 * R + 0.7152 * G + 0.0722 * B where R, G and B are defined as: if RsRGB <= 0.03928 then R = RsRGB/12.92 else R = ((RsRGB+0.055)/1.055) ^ 2.4 if GsRGB <= 0.03928 then G = GsRGB/12.92 else G = ((GsRGB+0.055)/1.055) ^ 2.4 if BsRGB <= 0.03928 then B = BsRGB/12.92 else B = ((BsRGB+0.055)/1.055) ^ 2.4
and RsRGB, GsRGB, and BsRGB are defined as: RsRGB = R8bit/255 GsRGB = G8bit/255 BsRGB = B8bit/255
An example implementation, outside of spectra but supporting spectra objects is as follows:
functionrelativeLuminance(color){// the relative brightness of any point in a colorspace, normalized to 0 for darkest black and 1 for lightest white// Note 1: For the sRGB colorspace, the relative luminance of a color is defined as L = 0.2126 * R + 0.7152 * G + 0.0722 * B where R, G and B are defined as:// if RsRGB <= 0.03928 then R = RsRGB/12.92 else R = ((RsRGB+0.055)/1.055) ^ 2.4// if GsRGB <= 0.03928 then G = GsRGB/12.92 else G = ((GsRGB+0.055)/1.055) ^ 2.4// if BsRGB <= 0.03928 then B = BsRGB/12.92 else B = ((BsRGB+0.055)/1.055) ^ 2.4// and RsRGB, GsRGB, and BsRGB are defined as:// RsRGB = R8bit/255// GsRGB = G8bit/255// BsRGB = B8bit/255// https://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef// convert spectra object into {r, g, b} objectif(color.color)color=color.color;varRsRGB=color.r/255;varGsRGB=color.g/255;varBsRGB=color.b/255;varR=RsRGB<=0.03928 ? RsRGB/12.92 : Math.pow((RsRGB+0.055)/1.055,2.4);varG=GsRGB<=0.03928 ? GsRGB/12.92 : Math.pow((GsRGB+0.055)/1.055,2.4);varB=BsRGB<=0.03928 ? BsRGB/12.92 : Math.pow((BsRGB+0.055)/1.055,2.4);varluminance=0.2126*R+0.7152*G+0.0722*B;returnluminance;}
The text was updated successfully, but these errors were encountered:
Azeirah
changed the title
The luminance, and therefore contrast value is calculated incorrectly
The luminance value is calculated incorrectly
Feb 11, 2017
According to the w3c on luminance, luminance gets calculated differently to Spectra's current implementation.
Spectra interprets this block of text as
But doesn't take into account the if statements.
An example implementation, outside of spectra but supporting spectra objects is as follows:
The text was updated successfully, but these errors were encountered: