Skip to main content

Timeline for RGB to hex and hex to RGB

Current License: CC BY-SA 4.0

9 events
when toggle format what by license comment
Mar 8 at 16:59 history edited Kamil Kiełczewski CC BY-SA 4.0
added 58 characters in body
Mar 8 at 11:28 comment added abe1432181 See stackoverflow.com/a/49974627/1432181 for rgba. See jsfiddle.net/Abeeee/ud1as8o3/1 for a running demo.
Oct 29, 2021 at 13:16 comment added Aryo Yes, the formula is not the actual formula for luminance. Using the actual luminance formula. Blue is somehow perceived darker than green/yellow at the same luminance level. So, there must be something to be changed from each color component. I got the code from here: stackoverflow.com/a/1754281/764788 which measure the brightness level according to a human perceived brightness level of each R, G, and B color and weight each of them respectively.
Oct 29, 2021 at 10:46 comment added Kamil Kiełczewski @Aryo according to wiki luminance (from hsl) is L = (max(R,G,B) + min(R,G,B))/2 - but I not test it. May be your formula is more based on eye physical properties...
Oct 29, 2021 at 10:35 comment added Aryo Nice! I use the following code to calculate the berightness level of the color (e.g. whether the color is dark or light to identify the text color for use with it.) Here's the code in Javascript to get the luminance: let rgb = color.match(/\w\w/g).map(x=>+`0x${x}`); let lum = (rgb[0]*0.299 + rgb[1]*0.587 + rgb[2]*0.114) / 256; lum > 0.5 is light/bright color
Jul 12, 2021 at 19:22 history edited Kamil Kiełczewski CC BY-SA 4.0
deleted 17 characters in body
Jul 15, 2020 at 22:08 history edited Kamil Kiełczewski CC BY-SA 4.0
added 55 characters in body
Mar 26, 2020 at 10:59 history edited Kamil Kiełczewski CC BY-SA 4.0
deleted 2 characters in body
Feb 21, 2020 at 22:39 history answered Kamil Kiełczewski CC BY-SA 4.0