Wednesday, 13 May 2009

HEXADECIMAL COLOUR

hex triplet is a six-digit, three-byte hexadecimal number used in HTMLCSSSVG, and other computing applications, to represent colors. The bytes represent the red, green and blue components of the color. One byte represents a number in the range 00 to FF (in hexadecimal notation), or 0 to 255 in decimal notation. This represents the least (0) to the most (255) intensity of each of the color components. The hex triplet is formed by concatenating three bytes in hexadecimal notation, in the following order:


Byte 1: red value (color type red)
Byte 2: green value (color type green)
Byte 3: blue value (color type blue)
:  #000000


For example, consider the color where the red/green/blue values are decimal numbers: red=36, green=104, blue=160 (a greyish-blue color). The decimal numbers 36, 104 and 160 are equivalent to the hexadecimal numbers 24, 68 and A0 respectively. The hex triplet is obtained by concatenating the 6 hexadecimal digits together, 2468A0 in this example.

Note that if any one of the three color values is less than 16 (decimal) or 10 (hex), it must be represented with a leading zero so that the triplet always has exactly six digits. For example, the decimal triplet 4, 8, 16 would be represented by the hex digits 04, 08, 10, forming the hex triplet 040810.

The number of colors that can be represented by this system is

256 \times 256 \times 256 = 16,777,216

An abbreviated, three (hexadecimal) digit form is sometimes used.[5] Expanding this form to the six-digit form is as simple as doubling each digit: 09C becomes 0099CC. This allows each color value to cover its full range from 00 to FF. The three-digit form is described in the CSS specification, not in HTML. As a result, the three digit form in an attribute other than "style" is not interpreted as a valid color in some browsers.[citation needed]

[edit]Converting RGB to hexadecimal

Converting a decimal RGB value to a hexadecimal value is fairly straightforward. RGB values are usually given in the 0-255 range; if they are in the 0-1 range, the values are multiplied by 255 before conversion. This number divided by 16 (integer division; ignoring any remainder) gives us the first hexadecimal digit (between 0 and F, where the letters A to F represent the numbers 10 to 15. See hexadecimal for more details). The remainder gives us the second hexadecimal digit. For instance the RGB value 201 divides into 12 groups of 16, thus the first digit is C. A remainder of 9 gives us the hexadecimal number C9. This process is repeated for each of the three color values. Most modern operating systems have a built-in calculator to perform conversions between number bases and this can also be done with some hand-held calculators. This task can also be carried out using various web resources.[6]

ColorHexadecimalColorHexadecimalColorHexadecimalColorHexadecimal
aqua#00FFFFgray (grey)#808080navy#000080silver#C0C0C0
black#000000green#008000olive#808000teal#008080
blue#0000FFlime#00FF00purple#800080white#FFFFFF
fuchsia#FF00FFmaroon#800000red#FF0000yellow#FFFF00


HTML nameHex code
R   G   B
Decimal code
R   G   B
Red colors
IndianRedCD 5C 5C205  92  92
LightCoralF0 80 80240 128 128
SalmonFA 80 72250 128 114
DarkSalmonE9 96 7A233 150 122
LightSalmonFF A0 7A255 160 122
CrimsonDC 14 3C220  20  60
RedFF 00 00255   0   0
FireBrickB2 22 22178  34  34
DarkRed8B 00 00139   0   0
Pink colors
PinkFF C0 CB255 192 203
LightPinkFF B6 C1255 182 193
HotPinkFF 69 B4255 105 180
DeepPinkFF 14 93255  20 147
MediumVioletRedC7 15 85199  21 133
PaleVioletRedDB 70 93219 112 147
Orange colors
LightSalmonFF A0 7A255 160 122
CoralFF 7F 50255 127  80
TomatoFF 63 47255  99  71
OrangeRedFF 45 00255  69   0
DarkOrangeFF 8C 00255 140   0
OrangeFF A5 00255 165   0
Yellow colors
GoldFF D7 00255 215   0
YellowFF FF 00255 255   0
LightYellowFF FF E0255 255 224
LemonChiffonFF FA CD255 250 205
LightGoldenrodYellowFA FA D2250 250 210
PapayaWhipFF EF D5255 239 213
MoccasinFF E4 B5255 228 181
PeachPuffFF DA B9255 218 185
PaleGoldenrodEE E8 AA238 232 170
KhakiF0 E6 8C240 230 140
DarkKhakiBD B7 6B189 183 107
Purple colors
LavenderE6 E6 FA230 230 250
ThistleD8 BF D8216 191 216
PlumDD A0 DD221 160 221
VioletEE 82 EE238 130 238
OrchidDA 70 D6218 112 214
FuchsiaFF 00 FF255   0 255
MagentaFF 00 FF255   0 255
MediumOrchidBA 55 D3186  85 211
MediumPurple93 70 DB147 112 219
Amethyst99 66 CC153 102 204
BlueViolet8A 2B E2138  43 226
DarkViolet94 00 D3148   0 211
DarkOrchid99 32 CC153  50 204
DarkMagenta8B 00 8B139   0 139
Purple80 00 80128   0 128
Indigo4B 00 82 75   0 130
SlateBlue6A 5A CD106  90 205
DarkSlateBlue48 3D 8B 72  61 139
MediumSlateBlue7B 68 EE123 104 238
HTML nameHex code
R   G   B
Decimal code
R   G   B
Green colors
GreenYellowAD FF 2F173 255  47
Chartreuse7F FF 00127 255   0
LawnGreen7C FC 00124 252   0
Lime00 FF 00  0 255   0
LimeGreen32 CD 32 50 205  50
PaleGreen98 FB 98152 251 152
LightGreen90 EE 90144 238 144
MediumSpringGreen00 FA 9A  0 250 154
SpringGreen00 FF 7F  0 255 127
MediumSeaGreen3C B3 71 60 179 113
SeaGreen2E 8B 57 46 139  87
ForestGreen22 8B 22 34 139  34
Green00 80 00  0 128   0
DarkGreen00 64 00  0 100   0
YellowGreen9A CD 32154 205  50
OliveDrab6B 8E 23107 142  35
Olive80 80 00128 128   0
DarkOliveGreen55 6B 2F 85 107  47
MediumAquamarine66 CD AA102 205 170
DarkSeaGreen8F BC 8F143 188 143
LightSeaGreen20 B2 AA 32 178 170
DarkCyan00 8B 8B  0 139 139
Teal00 80 80  0 128 128
Blue colors
Aqua00 FF FF  0 255 255
Cyan00 FF FF  0 255 255
LightCyanE0 FF FF224 255 255
PaleTurquoiseAF EE EE175 238 238
Aquamarine7F FF D4127 255 212
Turquoise40 E0 D0 64 224 208
MediumTurquoise48 D1 CC 72 209 204
DarkTurquoise00 CE D1  0 206 209
CadetBlue5F 9E A0 95 158 160
SteelBlue46 82 B4 70 130 180
LightSteelBlueB0 C4 DE176 196 222
PowderBlueB0 E0 E6176 224 230
LightBlueAD D8 E6173 216 230
SkyBlue87 CE EB135 206 235
LightSkyBlue87 CE FA135 206 250
DeepSkyBlue00 BF FF  0 191 255
DodgerBlue1E 90 FF 30 144 255
CornflowerBlue64 95 ED100 149 237
MediumSlateBlue7B 68 EE123 104 238
RoyalBlue41 69 E1 65 105 225
Blue00 00 FF  0   0 255
MediumBlue00 00 CD  0   0 205
DarkBlue00 00 8B  0   0 139
Navy00 00 80  0   0 128
MidnightBlue19 19 70 25  25 112
HTML nameHex code
R   G   B
Decimal code
R   G   B
Brown colors
CornsilkFF F8 DC255 248 220
BlanchedAlmondFF EB CD255 235 205
BisqueFF E4 C4255 228 196
NavajoWhiteFF DE AD255 222 173
WheatF5 DE B3245 222 179
BurlyWoodDE B8 87222 184 135
TanD2 B4 8C210 180 140
RosyBrownBC 8F 8F188 143 143
SandyBrownF4 A4 60244 164  96
GoldenrodDA A5 20218 165  32
DarkGoldenrodB8 86 0B184 134  11
PeruCD 85 3F205 133  63
ChocolateD2 69 1E210 105  30
SaddleBrown8B 45 13139  69  19
SiennaA0 52 2D160  82  45
BrownA5 2A 2A165  42  42
Maroon80 00 00128   0   0
White colors
WhiteFF FF FF255 255 255
SnowFF FA FA255 250 250
HoneydewF0 FF F0240 255 240
MintCreamF5 FF FA245 255 250
AzureF0 FF FF240 255 255
AliceBlueF0 F8 FF240 248 255
GhostWhiteF8 F8 FF248 248 255
WhiteSmokeF5 F5 F5245 245 245
SeashellFF F5 EE255 245 238
BeigeF5 F5 DC245 245 220
OldLaceFD F5 E6253 245 230
FloralWhiteFF FA F0255 250 240
IvoryFF FF F0255 255 240
AntiqueWhiteFA EB D7250 235 215
LinenFA F0 E6250 240 230
LavenderBlushFF F0 F5255 240 245
MistyRoseFF E4 E1255 228 225
Grey colors
GainsboroDC DC DC220 220 220
LightGreyD3 D3 D3211 211 211
SilverC0 C0 C0192 192 192
DarkGrayA9 A9 A9169 169 169
Gray80 80 80128 128 128
DimGray69 69 69105 105 105
LightSlateGray77 88 99119 136 153
SlateGray70 80 90112 128 144
DarkSlateGray2F 4F 4F 47  79  79
Black00 00 00  0   0   0

This post has taught me how Hex code works for colour. But it does not tell me how the initial coding language works. Hexadecimal is a way of condensing numbers down but what else can it be used for? how is it made up? what is the history of the code? Is it used for anything else?

No comments:

Post a Comment