Given RGB =
R:
100,
G:
150B:
230Calculate hex code and hue.
Calculate Piece 1 of the Red portion:
Red Piece 1 = | Red - Red mod 16 |
| 16 |
Red Piece 1 = | 100 - 100 mod 16 |
| 16 |
Check our
modulus lesson100 mod 16 = 4
Red Piece 1 = 6
In the string
0123456789ABCDEFWe use position 6 =
6Calculate Piece 2 of the Red portion:
Red Piece 2 =
Red mod 16
Red Piece 2 =
100 mod 16
Red Piece 2 = 4
In the string
0123456789ABCDEFWe use position 4 =
4Calculate Piece 1 of the Green portion:
Green Piece 1 = | Green - Green mod 16 |
| 16 |
Green Piece 1 = | 150 - 150 mod 16 |
| 16 |
Check our
modulus lesson150 mod 16 = 6
Green Piece 1 = | 150 - 6 |
| 16 |
Green Piece 1 = 9
In the string
0123456789ABCDEFWe use position 9 =
9Calculate Piece 2 of the Green portion:
Green Piece 2 =
Green mod 16
Green Piece 2 =
150 mod 16
Green Piece 2 = 6
In the string
0123456789ABCDEFWe use position 6 =
6Calculate Piece 1 of the Blue portion:
Blue Piece 1 = | Blue - Blue mod 16 |
| 16 |
Blue Piece 1 = | 230 - 230 mod 16 |
| 16 |
Check our
modulus lesson230 mod 16 = 6
Blue Piece 1 = | 230 - 6 |
| 16 |
Blue Piece 1 = 14
In the string
0123456789ABCDEFWe use position 14 =
ECalculate Piece 2 of the Blue portion:
Blue Piece 2 =
Blue mod 16
Blue Piece 2 =
230 mod 16
Blue Piece 2 = 6
In the string
0123456789ABCDEFWe use position 6 =
6Our final RGB to HEX conversion is below:
R:
100,
G:
150,
B:
230 → =
6 =
4 =
9 =
6 =
E =
6Calculate Hue for RGB = (100, 150, 230)
Since
B >
G >
R, we are in the Cyan-Blue region and the formula is below:
h = | 60°(4B - 5(R) - G) |
| B - R |
h = | 60°(4(230) - 5(100) - 230) |
| 230 - 100 |
h