@@ -40,41 +40,33 @@ function matchChannels ( hex : string ){
4040
4141
4242/**
43- * Parses hex color codes into their respective RGB(A) channels .
43+ * Parses a hex RGB(A) color code into a RGB(A) array .
4444 *
45- * @param hex Hex RGB(A) color code string.
46- * @returns Channels [ Red , Green , Blue , ( Alpha ) ] each ( 0 - 255 )
45+ * ### Examples
4746 *
47+ * Parsing a long form RGBA hex code with alpha:
4848 *
49- * ## Examples
49+ * ```typescript
50+ * const hex = '#FF000069' // Red
5051 *
51- * Long form RGBA color codes:
52+ * const rgb = hexToRGB(hex)
5253 *
53- * ```typescript
54- * hexToRGB('#AABBCCDD')
55- * hexToRGB('AABBCCDD')
54+ * console.debug(rgb) // [ 255 , 0 , 0 , 69 ]
5655 * ```
5756 *
58- * Long form RGB color codes :
57+ * Parsing a short form RGB hex code without # :
5958 *
6059 * ```typescript
61- * hexToRGB('#AABBCC')
62- * hexToRGB('AABBCC')
63- * ```
60+ * const hex = 'F00' // Red
6461 *
65- * Short form RGBA color codes:
62+ * const rgb = hexToRGB(hex)
6663 *
67- * ```typescript
68- * hexToRGB('#ABCD')
69- * hexToRGB('ABCD')
64+ * console.debug(rgb) // [ 255 , 0 , 0 ]
7065 * ```
7166 *
72- * Short form RGB color codes:
67+ * @param hex Hex RGB(A) color code string.
7368 *
74- * ```typescript
75- * hexToRGB('#ABC')
76- * hexToRGB('ABC')
77- * ```
69+ * @returns [ Hue 0 - 360 , Saturation 0 - 100 , Lightness 0 - 100 ]
7870 */
7971
8072function hexToRGB (
@@ -85,12 +77,45 @@ function hexToRGB (
8577
8678
8779/**
88- * Attempts to parse a string with a hex color code into its respective RGB(A) channels.
80+ * Attempts to parse a string as a RGB(A) hex color code into a RGB(A) array.
81+ *
82+ * ### Examples
83+ *
84+ * Parsing a long form RGBA hex code with alpha:
85+ *
86+ * ```typescript
87+ * const hex = '#FF000069' // Red
88+ *
89+ * const rgb = parseHexToRGB(hex)
90+ *
91+ * console.debug(rgb) // [ 255 , 0 , 0 , 69 ]
92+ * ```
93+ *
94+ * Parsing a short form RGB hex code without #:
95+ *
96+ * ```typescript
97+ * const hex = 'F00' // Red
98+ *
99+ * const rgb = parseHexToRGB(hex)
100+ *
101+ * console.debug(rgb) // [ 255 , 0 , 0 ]
102+ * ```
103+ *
104+ * Parsing an invalid hex color code:
105+ *
106+ * ```typescript
107+ * const hex = 'Invalid'
108+ *
109+ * const rgb = parseHexToRGB(hex)
110+ *
111+ * console.debug(rgb) // null
112+ * ```
113+ *
114+ * @param hex Hex RGB(A) color code string.
89115 *
90- * @param hex String possibly containing a hex RGB(A) color code.
91- * @returns null if not found, otherwise Channels [ Red , Green , Blue , ( Alpha ) ] each ( 0 - 255 )
116+ * @returns [ Hue 0 - 360 , Saturation 0 - 100 , Lightness 0 - 100 , ( Alpha 0 - 255 ) ]
92117 *
93- * Check { @link hexToRGB} for examples
118+ * Returns null if no color code could be matched.
94119 */
95120
96121function parseHexToRGB (
0 commit comments