How to know color from HEX value or RGB? | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 4

How to know color from HEX value or RGB?

For example, given something like "#e3b3d5" or this "RGB(142,184,168)", is there any way or formula to identify the color from these values given? Thanks, for your time

9th Jul 2022, 2:35 PM
umunyarwanda
umunyarwanda - avatar
4 Respuestas
+ 2
An RGB color value is specified with: rgb(red, green, blue). Each parameter (red, green, and blue) defines the intensity of the color as an integer between 0 and 255. For example, rgb(0, 0, 255) is rendered as blue, because the blue parameter is set to its highest value (255) and the others are set to 0.
9th Jul 2022, 3:08 PM
JaScript
JaScript - avatar
9th Jul 2022, 3:05 PM
Ervis Meta
Ervis Meta - avatar
+ 1
Explanation from Code Coach "Hex Code Generator": Hex color codes work within 15 characters, 0-9 and a-f. RGB goes into hex color codes as such # (red) 00 (green) 00 (blue) 00. Hex color codes work by rolling over the value of 09 to 0a. Once 0f is hit (15) the following value (16) would be represented as 10 instead of (16). This means the RGB values (16, 32, 161) would evaluate to #1020a1 (10, 20, a1). That means for your Hex would be first e0 (e = 15 c) 16*14 + 03 (3 = 3 c) also 227, next b3 = 16*11 + 03 = 179 and last d5 = 16*13 + 05 = 213. Means (#e3b3d5) == (RGB: 227, 179, 213) edit: Formel N(char number 1-9, a-f)*16+N
9th Jul 2022, 3:09 PM
Felix Alcor
Felix Alcor - avatar
0
For an intuitive approach, sometimes this could work. When you have a hex code it is composed of 6 hexadecimal digits where 0 is smallest and F is the highest value. It is a good clue to examine the first, third and fifth character, that puts the color scales in a general range. For example with code #e3b3d5 Red = E = high Green = B = medium high Blue = D = high We know that #000000 is black and #ffffff is white. So if all values are low, this is a dark shade, if all are high, it is a light shade. If all values are close to equal, the shade is greyish. In this case, all numbers are high but red (e) and blue (d) are more dominant, so it is a light pink / purple color.
10th Jul 2022, 5:36 AM
Tibor Santa
Tibor Santa - avatar