@trishchuk/coolors-mcp 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (197) hide show
  1. package/.claude/settings.local.json +39 -0
  2. package/.env +2 -0
  3. package/.github/ISSUE_TEMPLATE/bug_report.md +73 -0
  4. package/.github/ISSUE_TEMPLATE/feature_request.md +71 -0
  5. package/.github/pull_request_template.md +97 -0
  6. package/.github/workflows/ci.yml +127 -0
  7. package/.github/workflows/deploy-docs.yml +56 -0
  8. package/.github/workflows/release.yml +99 -0
  9. package/.mcp.json +12 -0
  10. package/.prettierignore +1 -0
  11. package/CLAUDE.md +201 -0
  12. package/DOCUMENTATION.md +274 -0
  13. package/GEMINI.md +54 -0
  14. package/LICENSE +21 -0
  15. package/README.md +401 -0
  16. package/demo/content_based_color.png +0 -0
  17. package/demo/music-player.html +621 -0
  18. package/demo/podcast-player.html +903 -0
  19. package/dist/bin/coolors-mcp.d.ts +1 -0
  20. package/dist/bin/coolors-mcp.js +154 -0
  21. package/dist/bin/coolors-mcp.js.map +1 -0
  22. package/dist/bin/server.d.ts +1 -0
  23. package/dist/bin/server.js +3292 -0
  24. package/dist/bin/server.js.map +1 -0
  25. package/dist/chunk-IQ7NN26V.js +114 -0
  26. package/dist/chunk-IQ7NN26V.js.map +1 -0
  27. package/dist/chunk-P3ARRKLS.js +1214 -0
  28. package/dist/chunk-P3ARRKLS.js.map +1 -0
  29. package/dist/color/index.d.ts +716 -0
  30. package/dist/color/index.js +153 -0
  31. package/dist/color/index.js.map +1 -0
  32. package/dist/coolors-mcp.d.ts +136 -0
  33. package/dist/coolors-mcp.js +7 -0
  34. package/dist/coolors-mcp.js.map +1 -0
  35. package/docs/.vitepress/cache/deps/@braintree_sanitize-url.js +93 -0
  36. package/docs/.vitepress/cache/deps/@braintree_sanitize-url.js.map +7 -0
  37. package/docs/.vitepress/cache/deps/_metadata.json +127 -0
  38. package/docs/.vitepress/cache/deps/chunk-BUSYA2B4.js +9 -0
  39. package/docs/.vitepress/cache/deps/chunk-BUSYA2B4.js.map +7 -0
  40. package/docs/.vitepress/cache/deps/chunk-JD3CXNQ6.js +12683 -0
  41. package/docs/.vitepress/cache/deps/chunk-JD3CXNQ6.js.map +7 -0
  42. package/docs/.vitepress/cache/deps/chunk-SYPOPCWC.js +9719 -0
  43. package/docs/.vitepress/cache/deps/chunk-SYPOPCWC.js.map +7 -0
  44. package/docs/.vitepress/cache/deps/cytoscape-cose-bilkent.js +4710 -0
  45. package/docs/.vitepress/cache/deps/cytoscape-cose-bilkent.js.map +7 -0
  46. package/docs/.vitepress/cache/deps/cytoscape.js +30278 -0
  47. package/docs/.vitepress/cache/deps/cytoscape.js.map +7 -0
  48. package/docs/.vitepress/cache/deps/dayjs.js +285 -0
  49. package/docs/.vitepress/cache/deps/dayjs.js.map +7 -0
  50. package/docs/.vitepress/cache/deps/debug.js +468 -0
  51. package/docs/.vitepress/cache/deps/debug.js.map +7 -0
  52. package/docs/.vitepress/cache/deps/package.json +3 -0
  53. package/docs/.vitepress/cache/deps/prismjs.js +1466 -0
  54. package/docs/.vitepress/cache/deps/prismjs.js.map +7 -0
  55. package/docs/.vitepress/cache/deps/prismjs_components_prism-bash.js +228 -0
  56. package/docs/.vitepress/cache/deps/prismjs_components_prism-bash.js.map +7 -0
  57. package/docs/.vitepress/cache/deps/prismjs_components_prism-javascript.js +142 -0
  58. package/docs/.vitepress/cache/deps/prismjs_components_prism-javascript.js.map +7 -0
  59. package/docs/.vitepress/cache/deps/prismjs_components_prism-json.js +27 -0
  60. package/docs/.vitepress/cache/deps/prismjs_components_prism-json.js.map +7 -0
  61. package/docs/.vitepress/cache/deps/prismjs_components_prism-python.js +65 -0
  62. package/docs/.vitepress/cache/deps/prismjs_components_prism-python.js.map +7 -0
  63. package/docs/.vitepress/cache/deps/prismjs_components_prism-typescript.js +53 -0
  64. package/docs/.vitepress/cache/deps/prismjs_components_prism-typescript.js.map +7 -0
  65. package/docs/.vitepress/cache/deps/prismjs_components_prism-yaml.js +73 -0
  66. package/docs/.vitepress/cache/deps/prismjs_components_prism-yaml.js.map +7 -0
  67. package/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js +4507 -0
  68. package/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js.map +7 -0
  69. package/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js +584 -0
  70. package/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js.map +7 -0
  71. package/docs/.vitepress/cache/deps/vitepress___@vueuse_integrations_useFocusTrap.js +1146 -0
  72. package/docs/.vitepress/cache/deps/vitepress___@vueuse_integrations_useFocusTrap.js.map +7 -0
  73. package/docs/.vitepress/cache/deps/vitepress___mark__js_src_vanilla__js.js +1667 -0
  74. package/docs/.vitepress/cache/deps/vitepress___mark__js_src_vanilla__js.js.map +7 -0
  75. package/docs/.vitepress/cache/deps/vitepress___minisearch.js +1814 -0
  76. package/docs/.vitepress/cache/deps/vitepress___minisearch.js.map +7 -0
  77. package/docs/.vitepress/cache/deps/vue.js +344 -0
  78. package/docs/.vitepress/cache/deps/vue.js.map +7 -0
  79. package/docs/.vitepress/components/ClientGrid.vue +125 -0
  80. package/docs/.vitepress/components/CodeBlock.vue +231 -0
  81. package/docs/.vitepress/components/ConfigModal.vue +477 -0
  82. package/docs/.vitepress/components/DiagramModal.vue +528 -0
  83. package/docs/.vitepress/components/TroubleshootingModal.vue +472 -0
  84. package/docs/.vitepress/config.js +162 -0
  85. package/docs/.vitepress/theme/FundingLayout.vue +251 -0
  86. package/docs/.vitepress/theme/Layout.vue +134 -0
  87. package/docs/.vitepress/theme/components/AdBanner.vue +317 -0
  88. package/docs/.vitepress/theme/components/AdPlaceholder.vue +78 -0
  89. package/docs/.vitepress/theme/components/FundingEffects.vue +322 -0
  90. package/docs/.vitepress/theme/components/FundingHero.vue +345 -0
  91. package/docs/.vitepress/theme/components/SupportSection.vue +511 -0
  92. package/docs/.vitepress/theme/custom-app.css +339 -0
  93. package/docs/.vitepress/theme/custom.css +699 -0
  94. package/docs/.vitepress/theme/index.js +25 -0
  95. package/docs/README.md +198 -0
  96. package/docs/concepts/accessibility.md +473 -0
  97. package/docs/concepts/color-spaces.md +222 -0
  98. package/docs/concepts/distance-metrics.md +384 -0
  99. package/docs/concepts/hct.md +261 -0
  100. package/docs/concepts/image-analysis.md +396 -0
  101. package/docs/concepts/material-design.md +306 -0
  102. package/docs/concepts/theme-matching.md +399 -0
  103. package/docs/examples/basic-colors.md +490 -0
  104. package/docs/examples/creating-themes.md +898 -0
  105. package/docs/examples/css-refactoring.md +824 -0
  106. package/docs/examples/image-extraction.md +882 -0
  107. package/docs/getting-started.md +366 -0
  108. package/docs/index.md +190 -0
  109. package/docs/installation.md +157 -0
  110. package/docs/tools/README.md +234 -0
  111. package/docs/tools/accessibility.md +614 -0
  112. package/docs/tools/color-operations.md +374 -0
  113. package/docs/tools/image-extraction.md +624 -0
  114. package/docs/tools/material-design.md +347 -0
  115. package/docs/tools/theme-matching.md +552 -0
  116. package/eslint.config.ts +14 -0
  117. package/examples/theme-matching.md +113 -0
  118. package/jsr.json +7 -0
  119. package/mcp-config.json +8 -0
  120. package/note.md +35 -0
  121. package/package.json +122 -0
  122. package/research_results.md +53 -0
  123. package/src/bin/coolors-mcp.ts +194 -0
  124. package/src/bin/server.ts +61 -0
  125. package/src/color/__tests__/conversions-argb.test.ts +198 -0
  126. package/src/color/__tests__/extract-colors.test.ts +360 -0
  127. package/src/color/__tests__/image-utils.test.ts +242 -0
  128. package/src/color/__tests__/reference-colors.test.ts +278 -0
  129. package/src/color/__tests__/round-trip.test.ts +197 -0
  130. package/src/color/conversions.test.ts +402 -0
  131. package/src/color/conversions.ts +393 -0
  132. package/src/color/dislike/__tests__/dislike-analyzer.test.ts +248 -0
  133. package/src/color/dislike/dislike-analyzer.ts +114 -0
  134. package/src/color/extract-colors.ts +228 -0
  135. package/src/color/hct/__tests__/hct-class.test.ts +232 -0
  136. package/src/color/hct/harmonization.ts +204 -0
  137. package/src/color/hct/hct-class.ts +109 -0
  138. package/src/color/hct/hct-solver.ts +168 -0
  139. package/src/color/hct/index.ts +39 -0
  140. package/src/color/hct/tonal-palette.ts +211 -0
  141. package/src/color/hct/types.ts +88 -0
  142. package/src/color/image-utils.ts +79 -0
  143. package/src/color/index.ts +87 -0
  144. package/src/color/material-theme.ts +157 -0
  145. package/src/color/metrics.test.ts +276 -0
  146. package/src/color/metrics.ts +281 -0
  147. package/src/color/quantize/__tests__/quantizer_celebi.test.ts +195 -0
  148. package/src/color/quantize/lab_point_provider.ts +55 -0
  149. package/src/color/quantize/point_provider.ts +27 -0
  150. package/src/color/quantize/quantizer_celebi.ts +51 -0
  151. package/src/color/quantize/quantizer_celebi_test.ts +71 -0
  152. package/src/color/quantize/quantizer_map.ts +47 -0
  153. package/src/color/quantize/quantizer_wsmeans.ts +232 -0
  154. package/src/color/quantize/quantizer_wu.ts +472 -0
  155. package/src/color/score/__tests__/score.test.ts +224 -0
  156. package/src/color/score/score.ts +175 -0
  157. package/src/color/types.ts +151 -0
  158. package/src/color/utils/color_utils.ts +292 -0
  159. package/src/color/utils/math_utils.ts +145 -0
  160. package/src/color/utils.test.ts +403 -0
  161. package/src/color/utils.ts +315 -0
  162. package/src/constants.ts +5 -0
  163. package/src/coolors-mcp.ts +37 -0
  164. package/src/examples/addition.ts +333 -0
  165. package/src/examples/color-demo.ts +125 -0
  166. package/src/examples/custom-logger.ts +201 -0
  167. package/src/examples/oauth-server.ts +113 -0
  168. package/src/examples/session-context.ts +269 -0
  169. package/src/session.ts +116 -0
  170. package/src/theme/__tests__/matcher.test.ts +180 -0
  171. package/src/theme/__tests__/parser.test.ts +148 -0
  172. package/src/theme/__tests__/refactor.test.ts +224 -0
  173. package/src/theme/index.ts +34 -0
  174. package/src/theme/matcher.ts +395 -0
  175. package/src/theme/parser.ts +392 -0
  176. package/src/theme/refactor.ts +360 -0
  177. package/src/theme/types.ts +152 -0
  178. package/src/tools/__tests__/gradient-generator.test.ts +206 -0
  179. package/src/tools/__tests__/palette-with-locks.test.ts +109 -0
  180. package/src/tools/color-conversion.tool.ts +54 -0
  181. package/src/tools/color-distance.tool.ts +41 -0
  182. package/src/tools/colors.ts +31 -0
  183. package/src/tools/contrast-checker.tool.ts +37 -0
  184. package/src/tools/dislike-analyzer.tool.ts +247 -0
  185. package/src/tools/gradient-generator.tool.ts +250 -0
  186. package/src/tools/image-extraction.tools.ts +289 -0
  187. package/src/tools/index.ts +39 -0
  188. package/src/tools/material-theme.tools.ts +250 -0
  189. package/src/tools/palette-generator.tool.ts +135 -0
  190. package/src/tools/palette-with-locks.tool.ts +221 -0
  191. package/src/tools/registry.ts +142 -0
  192. package/src/tools/simple-tools.ts +37 -0
  193. package/src/tools/theme-matching.tools.ts +334 -0
  194. package/src/types.ts +182 -0
  195. package/src/utils.ts +22 -0
  196. package/tsconfig.json +8 -0
  197. package/vitest.config.js +15 -0
@@ -0,0 +1,490 @@
1
+ # Basic Color Operations Examples
2
+
3
+ Learn how to perform essential color operations with Coolors MCP through practical examples.
4
+
5
+ ## Color Conversion
6
+
7
+ ### Simple Format Conversion
8
+
9
+ Convert colors between different formats:
10
+
11
+ ```javascript
12
+ // Hex to RGB
13
+ "Convert #6366f1 to RGB"
14
+ // Result: rgb(99, 102, 241)
15
+
16
+ // RGB to HSL
17
+ "Convert rgb(99, 102, 241) to HSL"
18
+ // Result: hsl(239, 84%, 67%)
19
+
20
+ // HSL to HCT
21
+ "Convert hsl(239, 84%, 67%) to HCT"
22
+ // Result: hct(265.8, 87.2, 47.9)
23
+
24
+ // Any format to LAB
25
+ "What is #6366f1 in LAB color space?"
26
+ // Result: lab(47.9, 35.2, -65.7)
27
+ ```
28
+
29
+ ### Batch Conversion
30
+
31
+ Convert multiple colors at once:
32
+
33
+ ```javascript
34
+ "Convert these colors to HSL: #6366f1, #ec4899, #10b981"
35
+
36
+ // Results:
37
+ // #6366f1 → hsl(239, 84%, 67%)
38
+ // #ec4899 → hsl(330, 81%, 60%)
39
+ // #10b981 → hsl(161, 79%, 40%)
40
+ ```
41
+
42
+ ### Round-Trip Conversion
43
+
44
+ Verify conversion accuracy:
45
+
46
+ ```javascript
47
+ // Original → HCT → Back to original
48
+ const original = "#6366f1";
49
+ const hct = "hct(265.8, 87.2, 47.9)";
50
+ const backToHex = "#6366f1"; // Perfect round-trip
51
+ ```
52
+
53
+ ## Color Palettes
54
+
55
+ ### Monochromatic Palette
56
+
57
+ Generate shades of a single color:
58
+
59
+ ```javascript
60
+ "Create a monochromatic palette from #6366f1"
61
+
62
+ // Result: 5 shades
63
+ [
64
+ "#1a1d4d", // Darkest
65
+ "#3336a3",
66
+ "#6366f1", // Original
67
+ "#9598ff",
68
+ "#c7c8ff" // Lightest
69
+ ]
70
+ ```
71
+
72
+ ### Complementary Colors
73
+
74
+ Find opposite colors on the color wheel:
75
+
76
+ ```javascript
77
+ "What is the complementary color of #6366f1?"
78
+
79
+ // Result:
80
+ {
81
+ original: "#6366f1",
82
+ complementary: "#f1ee66" // Yellow opposite of blue
83
+ }
84
+ ```
85
+
86
+ ### Analogous Colors
87
+
88
+ Get neighboring colors:
89
+
90
+ ```javascript
91
+ "Generate analogous colors for #6366f1"
92
+
93
+ // Result: Colors 30° apart
94
+ [
95
+ "#8c66f1", // Purple-blue
96
+ "#6366f1", // Original blue
97
+ "#66c6f1" // Cyan-blue
98
+ ]
99
+ ```
100
+
101
+ ### Triadic Color Scheme
102
+
103
+ Three colors evenly spaced on the color wheel:
104
+
105
+ ```javascript
106
+ "Create a triadic color scheme from #6366f1"
107
+
108
+ // Result: Colors 120° apart
109
+ [
110
+ "#6366f1", // Blue (original)
111
+ "#f16366", // Red
112
+ "#66f163" // Green
113
+ ]
114
+ ```
115
+
116
+ ### Tetradic (Square) Scheme
117
+
118
+ Four colors evenly spaced:
119
+
120
+ ```javascript
121
+ "Generate a tetradic palette from #6366f1"
122
+
123
+ // Result: Colors 90° apart
124
+ [
125
+ "#6366f1", // Blue
126
+ "#f166c6", // Magenta
127
+ "#f1ee66", // Yellow
128
+ "#66f18c" // Green
129
+ ]
130
+ ```
131
+
132
+ ## Contrast Checking
133
+
134
+ ### Basic Contrast Check
135
+
136
+ ```javascript
137
+ "Check contrast between #1f2937 and #ffffff"
138
+
139
+ // Result:
140
+ {
141
+ ratio: 15.74,
142
+ passes: {
143
+ AA: { normal: true, large: true },
144
+ AAA: { normal: true, large: true }
145
+ },
146
+ recommendation: "Excellent contrast for all uses"
147
+ }
148
+ ```
149
+
150
+ ### Text on Background
151
+
152
+ ```javascript
153
+ "Is #6366f1 readable on white background?"
154
+
155
+ // Result:
156
+ {
157
+ ratio: 3.03,
158
+ passes: {
159
+ AA: { normal: false, large: true },
160
+ AAA: { normal: false, large: false }
161
+ },
162
+ recommendation: "Use for large text only (24px+)"
163
+ }
164
+ ```
165
+
166
+ ### Finding Accessible Colors
167
+
168
+ ```javascript
169
+ "What text color works on #6366f1 background?"
170
+
171
+ // Suggestions:
172
+ [
173
+ { color: "#ffffff", ratio: 4.6 }, // White text
174
+ { color: "#f0f0f0", ratio: 4.2 }, // Light gray
175
+ { color: "#000000", ratio: 4.5 } // Black text
176
+ ]
177
+ ```
178
+
179
+ ## Color Distance
180
+
181
+ ### Perceptual Similarity
182
+
183
+ ```javascript
184
+ "How similar are #6366f1 and #5355d1?"
185
+
186
+ // Result using Delta E 2000:
187
+ {
188
+ distance: 5.2,
189
+ interpretation: "Noticeable difference but related",
190
+ metric: "deltaE2000"
191
+ }
192
+ ```
193
+
194
+ ### Finding Similar Colors
195
+
196
+ ```javascript
197
+ "Find colors similar to #6366f1 in this palette"
198
+
199
+ const palette = ["#5355d1", "#7c3aed", "#6366f1", "#3b82f6"];
200
+
201
+ // Results (ΔE < 10):
202
+ [
203
+ { color: "#5355d1", distance: 5.2 }, // Very similar
204
+ { color: "#3b82f6", distance: 8.7 } // Similar
205
+ ]
206
+ ```
207
+
208
+ ### Color Matching Threshold
209
+
210
+ ```javascript
211
+ "Are these colors close enough to match? #6366f0 and #6366f1"
212
+
213
+ // Result:
214
+ {
215
+ distance: 0.4,
216
+ match: true,
217
+ confidence: 99.5,
218
+ interpretation: "Imperceptible difference"
219
+ }
220
+ ```
221
+
222
+ ## Gradients
223
+
224
+ ### Two-Color Gradient
225
+
226
+ ```javascript
227
+ "Create a gradient from #6366f1 to #ec4899"
228
+
229
+ // Result: 5 steps
230
+ [
231
+ "#6366f1", // Start
232
+ "#8757d5",
233
+ "#ab49b9",
234
+ "#ce3a9d",
235
+ "#ec4899" // End
236
+ ]
237
+ ```
238
+
239
+ ### Multi-Stop Gradient
240
+
241
+ ```javascript
242
+ "Create a gradient: #6366f1 → #ec4899 → #10b981"
243
+
244
+ // Result: Smooth transition through all colors
245
+ [
246
+ "#6366f1",
247
+ "#a154c5",
248
+ "#ec4899",
249
+ "#a9636d",
250
+ "#10b981"
251
+ ]
252
+ ```
253
+
254
+ ### Perceptual Gradient
255
+
256
+ ```javascript
257
+ "Create a perceptually smooth gradient from blue to yellow"
258
+
259
+ // Using LAB interpolation:
260
+ [
261
+ "#0000ff", // Blue
262
+ "#4040df",
263
+ "#8080bf",
264
+ "#c0c09f",
265
+ "#ffff00" // Yellow
266
+ ]
267
+ // Avoids muddy colors in the middle
268
+ ```
269
+
270
+ ## Practical Color Operations
271
+
272
+ ### Lighten and Darken
273
+
274
+ ```javascript
275
+ "Make #6366f1 20% lighter"
276
+ // Result: #8c8ff5
277
+
278
+ "Make #6366f1 30% darker"
279
+ // Result: #3a3d94
280
+ ```
281
+
282
+ ### Saturation Adjustment
283
+
284
+ ```javascript
285
+ "Desaturate #6366f1 by 50%"
286
+ // Result: #8a8cc4 (more gray)
287
+
288
+ "Make #6366f1 more vibrant"
289
+ // Result: #5050ff (higher chroma)
290
+ ```
291
+
292
+ ### Mix Colors
293
+
294
+ ```javascript
295
+ "Mix #6366f1 and #ec4899"
296
+ // Result: #a857c5 (purple)
297
+
298
+ "Mix #ff0000 and #00ff00 and #0000ff equally"
299
+ // Result: #808080 (gray)
300
+ ```
301
+
302
+ ## Real-World Examples
303
+
304
+ ### Button States
305
+
306
+ ```javascript
307
+ // Generate button color variations
308
+ const primary = "#6366f1";
309
+
310
+ const buttonStates = {
311
+ default: primary,
312
+ hover: lighten(primary, 10), // #797cf3
313
+ active: darken(primary, 10), // #5053d0
314
+ disabled: desaturate(primary, 60) // #9a9bc7
315
+ };
316
+ ```
317
+
318
+ ### Status Colors
319
+
320
+ ```javascript
321
+ // Create accessible status colors
322
+ const statusColors = {
323
+ success: {
324
+ bg: "#10b981",
325
+ text: "#ffffff", // Contrast: 4.5:1 ✓
326
+ },
327
+ warning: {
328
+ bg: "#f59e0b",
329
+ text: "#000000", // Contrast: 10.7:1 ✓
330
+ },
331
+ error: {
332
+ bg: "#ef4444",
333
+ text: "#ffffff", // Contrast: 4.5:1 ✓
334
+ },
335
+ info: {
336
+ bg: "#3b82f6",
337
+ text: "#ffffff", // Contrast: 4.6:1 ✓
338
+ }
339
+ };
340
+ ```
341
+
342
+ ### Brand Color System
343
+
344
+ ```javascript
345
+ // Build a complete color system from brand color
346
+ const brand = "#6366f1";
347
+
348
+ const colorSystem = {
349
+ // Primary shades
350
+ primary: {
351
+ 50: "#eef2ff",
352
+ 100: "#e0e7ff",
353
+ 500: brand,
354
+ 900: "#312e81"
355
+ },
356
+
357
+ // Grays from brand
358
+ gray: generateNeutralPalette(brand),
359
+
360
+ // Semantic colors
361
+ semantic: {
362
+ success: harmonize("#10b981", brand),
363
+ warning: harmonize("#f59e0b", brand),
364
+ error: harmonize("#ef4444", brand)
365
+ }
366
+ };
367
+ ```
368
+
369
+ ### Form Field Colors
370
+
371
+ ```javascript
372
+ // Accessible form field colors
373
+ const input = {
374
+ background: "#ffffff",
375
+ border: "#d1d5db", // 3:1 contrast ✓
376
+ text: "#1f2937", // 15.7:1 contrast ✓
377
+ placeholder: "#9ca3af", // 4.5:1 contrast ✓
378
+ focus: "#6366f1", // 3:1 contrast ✓
379
+ error: "#ef4444" // 4.5:1 contrast ✓
380
+ };
381
+ ```
382
+
383
+ ## Color Utilities
384
+
385
+ ### Get Luminance
386
+
387
+ ```javascript
388
+ "What is the luminance of #6366f1?"
389
+ // Result: 0.166 (scale 0-1)
390
+ ```
391
+
392
+ ### Get Dominant Channel
393
+
394
+ ```javascript
395
+ "Which color channel is strongest in #6366f1?"
396
+ // Result: Blue (241 of 255)
397
+ ```
398
+
399
+ ### Color Temperature
400
+
401
+ ```javascript
402
+ "Is #6366f1 a warm or cool color?"
403
+ // Result: Cool (blue hue at 239°)
404
+
405
+ "Is #ff6b6b warm or cool?"
406
+ // Result: Warm (red hue at 0°)
407
+ ```
408
+
409
+ ## Common Patterns
410
+
411
+ ### Theme-Safe Colors
412
+
413
+ ```javascript
414
+ // Ensure colors work in both light and dark themes
415
+ function getThemeSafeColor(color) {
416
+ const lightContrast = checkContrast(color, "#ffffff");
417
+ const darkContrast = checkContrast(color, "#000000");
418
+
419
+ if (lightContrast.ratio >= 4.5 && darkContrast.ratio >= 4.5) {
420
+ return color; // Works on both
421
+ }
422
+
423
+ // Adjust if needed
424
+ return adjustForBothThemes(color);
425
+ }
426
+ ```
427
+
428
+ ### Color Validation
429
+
430
+ ```javascript
431
+ // Validate color format
432
+ function validateColor(input) {
433
+ const formats = [
434
+ /^#[0-9a-f]{6}$/i, // Hex
435
+ /^rgb\(\d+,\s*\d+,\s*\d+\)$/, // RGB
436
+ /^hsl\(\d+,\s*\d+%,\s*\d+%\)$/ // HSL
437
+ ];
438
+
439
+ return formats.some(regex => regex.test(input));
440
+ }
441
+ ```
442
+
443
+ ### Palette Generation
444
+
445
+ ```javascript
446
+ // Generate a complete palette
447
+ function generatePalette(baseColor, options = {}) {
448
+ const {
449
+ shades = 5,
450
+ includeComplementary = true,
451
+ includeAnalogous = true
452
+ } = options;
453
+
454
+ return {
455
+ base: baseColor,
456
+ shades: generateShades(baseColor, shades),
457
+ complementary: includeComplementary ? getComplement(baseColor) : null,
458
+ analogous: includeAnalogous ? getAnalogous(baseColor) : null
459
+ };
460
+ }
461
+ ```
462
+
463
+ ## Tips and Best Practices
464
+
465
+ ### Color Conversion
466
+ - ✅ Use HCT for perceptual operations
467
+ - ✅ Use RGB/Hex for final output
468
+ - ❌ Don't chain too many conversions
469
+
470
+ ### Palette Generation
471
+ - ✅ Start with 5-7 colors maximum
472
+ - ✅ Test palettes with color blindness simulators
473
+ - ❌ Don't use pure black (#000000) with pure white
474
+
475
+ ### Contrast Checking
476
+ - ✅ Always check against actual backgrounds
477
+ - ✅ Test at different font sizes
478
+ - ❌ Don't rely on color alone for meaning
479
+
480
+ ### Gradients
481
+ - ✅ Use LAB/HCT for smooth gradients
482
+ - ✅ Limit to 5-10 steps for performance
483
+ - ❌ Don't interpolate in RGB (causes muddy colors)
484
+
485
+ ## Next Steps
486
+
487
+ - Try [Creating Themes](./creating-themes.md) for complete design systems
488
+ - Learn [CSS Refactoring](./css-refactoring.md) to modernize stylesheets
489
+ - Explore [Image Extraction](./image-extraction.md) for dynamic colors
490
+ - Read about [Distance Metrics](../concepts/distance-metrics.md) for color matching