Color Notation Conversion
DATE | FUNCTION | DESCRIPTION |
11/30/2019 | function hexa2rgb(hexcolor) | Return RGB from hexadecimal |
1/30/2019 | function rgb2hexa(r, b, g) | Returns hexadecimal from RGB |
Color Space Conversion
DATE | FUNCTION | DESCRIPTION |
11/29/2019 | function rgb2hsl(red, green, blue) | Converts RGB to HSL |
11/30/2019 | function hsl2rgb(hue, saturation, luma) | Converts HSL to RGB |
12/10/2019 | function rgb2hsv(red, green, blue) | Converts RGB to HSV |
12/12/2019 | function hsv2rgb(hue, sat, value) | Converts HSV to RGB |
Color Schemes
DATE | FUNCTION | DESCRIPTION | NOTES |
12/08/2019 | function complements(red, green, blue) | Takes red, green, and blue parameters, converts this into a hue. Returns hue and hue + 180. Colors returned as RGB values. | |
12/08/2019 | function splitcomplements(red, green, blue) | Takes red, green, and blue parameters, converts this into a hue. Returns hue, hue + (180 + 20), and hue + (180 – 20). Colors returned as RGB values. | Code should be expanded to control the step value (20). |
12/08/2019 | function analogous(red, green, blue) | Takes red, green, and blue parameters, converts this into a hue. Returns hue, hue + 10, hue – 10, hue + 20, hue – 20. Colors returned as RGB values. | Code should be expanded to control the step values (10, 20). |
12/08/2019 | function triadics(red, green, blue) | Takes red, green, and blue parameters, converts this into a hue. Returns hue & hue + 120, hue – 120. Colors returned as RGB values. | |
12/08/2019 | function tetradics(red, green, blue) | Takes red, green, and blue parameters, converts this into a hue. Returns hue & hue + 90, hue + 180, hue + 270. Colors returned as RGB values. |
Linear Gradient
01/19/2021
Although JavaScript + HTML5 has native ability to generate a linear gradient. This linear gradient function was necessary for my work because it allows more control over the gradient increment. Code also is able to generates the RGB values for each step in the linear gradient as an array. Using the array, one can treat the linear gradient as a color calculator to:
- find a color based on the array index
- find a colors corresponding opposite
- find the middle value (blend) of any two colors
Color Difference
01/31/2020
Find the color difference between two RGB values…
var colordiff = Math.sqrt(Math.pow((colorB[0] - colorA[0]), 2) + Math.pow((colorB[1] - colorA[1]), 2) + Math.pow((colorB[2] - colorA[2]), 2));
This formula is not the “best” formula, as it does not take into account how the human eye senses colors. Formulas (weighted RGB, redmean) that better approximate this value are well known.