blecsd 0.6.0 → 0.6.2

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 (78) hide show
  1. package/README.md +50 -28
  2. package/dist/blend-BZDmQFAm.d.ts +1215 -0
  3. package/dist/chunk-3PGACJB6.js +1 -0
  4. package/dist/chunk-4XW4WIPH.js +1 -0
  5. package/dist/chunk-7CLV3LTZ.js +4 -0
  6. package/dist/chunk-APPZ3YHO.js +0 -0
  7. package/dist/chunk-EKE2BXPS.js +1 -0
  8. package/dist/chunk-ESMSDY3P.js +1 -0
  9. package/dist/chunk-FJLSHFCF.js +1 -0
  10. package/dist/chunk-GIMWA5WA.js +1 -0
  11. package/dist/chunk-IXUFU6TE.js +3 -0
  12. package/dist/chunk-JB5KFQPD.js +1 -0
  13. package/dist/chunk-JCLNGU3K.js +1 -0
  14. package/dist/chunk-JRRJCATR.js +1 -0
  15. package/dist/{chunk-UKVY43V3.js → chunk-JWIVZCKW.js} +1 -1
  16. package/dist/chunk-K5UMVDQX.js +1 -0
  17. package/dist/chunk-L4FIDOS6.js +1 -0
  18. package/dist/chunk-LIVVHEOU.js +1 -0
  19. package/dist/chunk-M5FXA5FL.js +1 -0
  20. package/dist/{chunk-XH5GTWCV.js → chunk-MEJJLDEQ.js} +1 -1
  21. package/dist/chunk-NYIMY4UV.js +1 -0
  22. package/dist/chunk-PQZTNWLA.js +1 -0
  23. package/dist/chunk-SXOBHRXF.js +2 -0
  24. package/dist/chunk-T2EQLWMN.js +1 -0
  25. package/dist/chunk-T62UPG63.js +4 -0
  26. package/dist/chunk-TPBILYDM.js +10 -0
  27. package/dist/chunk-UWS6FIU5.js +1 -0
  28. package/dist/{chunk-4N7IFBRQ.js → chunk-W64J7C25.js} +1 -1
  29. package/dist/chunk-W6RELN6A.js +1 -0
  30. package/dist/chunk-ZAJI53SZ.js +1 -0
  31. package/dist/components/index.d.ts +3 -318
  32. package/dist/components/index.js +5 -5
  33. package/dist/core/index.d.ts +6 -251
  34. package/dist/core/index.js +1 -1
  35. package/dist/debug/index.js +7 -7
  36. package/dist/{dirtyTracking-kCS9-NVF.d.ts → dirtyTracking-D0SQrEeo.d.ts} +1 -1
  37. package/dist/{doubleBuffer-CWASihKh.d.ts → doubleBuffer-d9yVNtj1.d.ts} +21 -1
  38. package/dist/{mouseParser-CCqSEUVN.d.ts → events-CGqK6LGt.d.ts} +1 -176
  39. package/dist/index.d.ts +10 -9
  40. package/dist/index.js +1 -1
  41. package/dist/{inputStream-COARA4CP.d.ts → inputStream-BoFAEJ7g.d.ts} +205 -2
  42. package/dist/{interactiveSystem-h92W9W4n.d.ts → interactiveSystem-Dtv3xERg.d.ts} +316 -1
  43. package/dist/mouseParser-CTNGolIA.d.ts +177 -0
  44. package/dist/{panelMovement-DGzIQ8Ll.d.ts → panelMovement-DSLYdNOL.d.ts} +5 -4
  45. package/dist/style/index.d.ts +851 -0
  46. package/dist/style/index.js +1 -0
  47. package/dist/styleInheritance-CuRb5Dmp.d.ts +251 -0
  48. package/dist/systems/index.d.ts +6 -5
  49. package/dist/systems/index.js +1 -1
  50. package/dist/terminal/index.d.ts +201 -1295
  51. package/dist/terminal/index.js +1 -1
  52. package/dist/testing/index.d.ts +923 -0
  53. package/dist/testing/index.js +7 -0
  54. package/dist/text/index.js +1 -1
  55. package/dist/{textWrap-Ct2J8gO6.d.ts → textWrap-sY-PZzE7.d.ts} +1 -1
  56. package/dist/utils/index.d.ts +2 -2
  57. package/dist/widgets/bigText.js +1 -1
  58. package/dist/widgets/fonts/index.js +1 -1
  59. package/dist/widgets/index.js +18 -18
  60. package/package.json +16 -2
  61. package/dist/chunk-5YWRP2KG.js +0 -3
  62. package/dist/chunk-73Y45MLV.js +0 -12
  63. package/dist/chunk-A3GSH6MV.js +0 -1
  64. package/dist/chunk-A5B2BGUM.js +0 -1
  65. package/dist/chunk-EMZA6G2M.js +0 -4
  66. package/dist/chunk-ETFDYZVJ.js +0 -1
  67. package/dist/chunk-IANAVH2A.js +0 -1
  68. package/dist/chunk-JVMNMAHX.js +0 -1
  69. package/dist/chunk-K2QWNDXV.js +0 -1
  70. package/dist/chunk-LI3ZYXUT.js +0 -1
  71. package/dist/chunk-QABNK7IA.js +0 -1
  72. package/dist/chunk-QTDRFJG2.js +0 -1
  73. package/dist/chunk-SVHITP3F.js +0 -2
  74. package/dist/chunk-VIT4KE6Q.js +0 -1
  75. package/dist/chunk-XG5PVDOP.js +0 -1
  76. package/dist/chunk-YRSSCEAS.js +0 -1
  77. package/dist/chunk-ZL46COQF.js +0 -1
  78. /package/dist/{chunk-4XCFTNGN.js → chunk-4EV3YS7F.js} +0 -0
@@ -0,0 +1,1215 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * 256-color palette definitions and types
5
+ * @module terminal/colors/palette
6
+ */
7
+
8
+ /**
9
+ * Branded type for 256-color palette indices (0-255).
10
+ * Prevents accidentally passing arbitrary numbers where color indices are expected.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * import { Color256, isColor256 } from 'blecsd';
15
+ *
16
+ * const color: Color256 = 196 as Color256; // Red
17
+ * if (isColor256(userInput)) {
18
+ * // Safe to use as color index
19
+ * }
20
+ * ```
21
+ */
22
+ type Color256 = number & {
23
+ readonly __brand: 'Color256';
24
+ };
25
+ /**
26
+ * RGB color representation with values from 0-255.
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * import type { RGB } from 'blecsd';
31
+ *
32
+ * const red: RGB = { r: 255, g: 0, b: 0 };
33
+ * ```
34
+ */
35
+ interface RGB {
36
+ readonly r: number;
37
+ readonly g: number;
38
+ readonly b: number;
39
+ }
40
+ /**
41
+ * RGBA color with alpha channel (0-1).
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * import type { RGBA } from 'blecsd';
46
+ *
47
+ * const semiTransparentRed: RGBA = { r: 255, g: 0, b: 0, a: 0.5 };
48
+ * ```
49
+ */
50
+ interface RGBA extends RGB {
51
+ readonly a: number;
52
+ }
53
+ /**
54
+ * HSL color representation.
55
+ * - h: Hue (0-360)
56
+ * - s: Saturation (0-100)
57
+ * - l: Lightness (0-100)
58
+ *
59
+ * @example
60
+ * ```typescript
61
+ * import type { HSL } from 'blecsd';
62
+ *
63
+ * const red: HSL = { h: 0, s: 100, l: 50 };
64
+ * ```
65
+ */
66
+ interface HSL {
67
+ readonly h: number;
68
+ readonly s: number;
69
+ readonly l: number;
70
+ }
71
+ /**
72
+ * HSLA color with alpha channel.
73
+ */
74
+ interface HSLA extends HSL {
75
+ readonly a: number;
76
+ }
77
+ /**
78
+ * Schema for validating 256-color palette indices.
79
+ *
80
+ * @example
81
+ * ```typescript
82
+ * import { Color256Schema } from 'blecsd';
83
+ *
84
+ * const result = Color256Schema.safeParse(196);
85
+ * if (result.success) {
86
+ * console.log('Valid color:', result.data);
87
+ * }
88
+ * ```
89
+ */
90
+ declare const Color256Schema: z.ZodPipe<z.ZodNumber, z.ZodTransform<Color256, number>>;
91
+ /**
92
+ * Schema for RGB color objects.
93
+ *
94
+ * @example
95
+ * ```typescript
96
+ * import { RGBSchema } from 'blecsd';
97
+ *
98
+ * const result = RGBSchema.safeParse({ r: 255, g: 128, b: 0 });
99
+ * ```
100
+ */
101
+ declare const RGBSchema: z.ZodObject<{
102
+ r: z.ZodNumber;
103
+ g: z.ZodNumber;
104
+ b: z.ZodNumber;
105
+ }, z.core.$strip>;
106
+ /**
107
+ * Schema for RGBA color objects.
108
+ */
109
+ declare const RGBASchema: z.ZodObject<{
110
+ r: z.ZodNumber;
111
+ g: z.ZodNumber;
112
+ b: z.ZodNumber;
113
+ a: z.ZodNumber;
114
+ }, z.core.$strip>;
115
+ /**
116
+ * Schema for HSL color objects.
117
+ */
118
+ declare const HSLSchema: z.ZodObject<{
119
+ h: z.ZodNumber;
120
+ s: z.ZodNumber;
121
+ l: z.ZodNumber;
122
+ }, z.core.$strip>;
123
+ /**
124
+ * Schema for HSLA color objects.
125
+ */
126
+ declare const HSLASchema: z.ZodObject<{
127
+ h: z.ZodNumber;
128
+ s: z.ZodNumber;
129
+ l: z.ZodNumber;
130
+ a: z.ZodNumber;
131
+ }, z.core.$strip>;
132
+ /**
133
+ * Schema for hex color strings (#RGB, #RRGGBB, or #RRGGBBAA).
134
+ *
135
+ * @example
136
+ * ```typescript
137
+ * import { HexColorSchema } from 'blecsd';
138
+ *
139
+ * HexColorSchema.parse('#ff0000'); // Valid
140
+ * HexColorSchema.parse('#f00'); // Valid (shorthand)
141
+ * HexColorSchema.parse('#ff000080'); // Valid (with alpha)
142
+ * ```
143
+ */
144
+ declare const HexColorSchema: z.ZodString;
145
+ /**
146
+ * Checks if a number is a valid 256-color palette index.
147
+ *
148
+ * @param value - The value to check
149
+ * @returns True if value is a valid Color256
150
+ *
151
+ * @example
152
+ * ```typescript
153
+ * import { isColor256 } from 'blecsd';
154
+ *
155
+ * if (isColor256(userInput)) {
156
+ * // userInput is now typed as Color256
157
+ * }
158
+ * ```
159
+ */
160
+ declare function isColor256(value: unknown): value is Color256;
161
+ /**
162
+ * Asserts that a number is a valid Color256 and returns it typed.
163
+ * Throws if invalid.
164
+ *
165
+ * @param value - The value to convert
166
+ * @returns The value as Color256
167
+ * @throws Error if value is not a valid color index
168
+ *
169
+ * @example
170
+ * ```typescript
171
+ * import { asColor256 } from 'blecsd';
172
+ *
173
+ * const color = asColor256(196); // Returns 196 as Color256
174
+ * asColor256(256); // Throws Error
175
+ * ```
176
+ */
177
+ declare function asColor256(value: number): Color256;
178
+ /**
179
+ * Type guard for RGB objects.
180
+ */
181
+ declare function isRGB(value: unknown): value is RGB;
182
+ /**
183
+ * Complete 256-color palette as RGB values.
184
+ * - Indices 0-15: Standard ANSI colors
185
+ * - Indices 16-231: 6x6x6 color cube
186
+ * - Indices 232-255: 24-step grayscale
187
+ *
188
+ * @example
189
+ * ```typescript
190
+ * import { PALETTE_RGB } from 'blecsd';
191
+ *
192
+ * const red = PALETTE_RGB[9]; // { r: 255, g: 0, b: 0 }
193
+ * const gray = PALETTE_RGB[240]; // Grayscale value
194
+ * ```
195
+ */
196
+ declare const PALETTE_RGB: readonly RGB[];
197
+ /**
198
+ * Complete 256-color palette as hex strings.
199
+ *
200
+ * @example
201
+ * ```typescript
202
+ * import { PALETTE_HEX } from 'blecsd';
203
+ *
204
+ * const red = PALETTE_HEX[9]; // '#ff0000'
205
+ * ```
206
+ */
207
+ declare const PALETTE_HEX: readonly string[];
208
+ /**
209
+ * Get the RGB value for a 256-color palette index.
210
+ *
211
+ * @param color - The palette index (0-255)
212
+ * @returns The RGB color value
213
+ *
214
+ * @example
215
+ * ```typescript
216
+ * import { getRGB } from 'blecsd';
217
+ *
218
+ * const rgb = getRGB(196 as Color256);
219
+ * console.log(rgb); // { r: 255, g: 0, b: 95 }
220
+ * ```
221
+ */
222
+ declare function getRGB(color: Color256): RGB;
223
+ /**
224
+ * Get the hex string for a 256-color palette index.
225
+ *
226
+ * @param color - The palette index (0-255)
227
+ * @returns The hex color string
228
+ *
229
+ * @example
230
+ * ```typescript
231
+ * import { getHex } from 'blecsd';
232
+ *
233
+ * const hex = getHex(196 as Color256);
234
+ * console.log(hex); // '#ff005f'
235
+ * ```
236
+ */
237
+ declare function getHex(color: Color256): string;
238
+ /**
239
+ * The 6 intensity levels used in the 256-color cube.
240
+ */
241
+ declare const COLOR_CUBE_LEVELS: readonly [0, 95, 135, 175, 215, 255];
242
+ /**
243
+ * Get the color cube index for given R, G, B levels (0-5 each).
244
+ *
245
+ * @param r - Red level (0-5)
246
+ * @param g - Green level (0-5)
247
+ * @param b - Blue level (0-5)
248
+ * @returns The palette index (16-231)
249
+ *
250
+ * @example
251
+ * ```typescript
252
+ * import { colorCubeIndex } from 'blecsd';
253
+ *
254
+ * const index = colorCubeIndex(5, 0, 1); // Bright red with slight blue
255
+ * ```
256
+ */
257
+ declare function colorCubeIndex(r: number, g: number, b: number): Color256;
258
+ /**
259
+ * Get the grayscale palette index for a given step (0-23).
260
+ *
261
+ * @param step - Grayscale step (0-23, where 0 is darkest)
262
+ * @returns The palette index (232-255)
263
+ *
264
+ * @example
265
+ * ```typescript
266
+ * import { grayscaleIndex } from 'blecsd';
267
+ *
268
+ * const darkGray = grayscaleIndex(5);
269
+ * const lightGray = grayscaleIndex(20);
270
+ * ```
271
+ */
272
+ declare function grayscaleIndex(step: number): Color256;
273
+ /**
274
+ * Check if a palette index is in the standard color range (0-15).
275
+ */
276
+ declare function isStandardColor(color: Color256): boolean;
277
+ /**
278
+ * Check if a palette index is in the color cube range (16-231).
279
+ */
280
+ declare function isColorCube(color: Color256): boolean;
281
+ /**
282
+ * Check if a palette index is in the grayscale range (232-255).
283
+ */
284
+ declare function isGrayscale(color: Color256): boolean;
285
+ /**
286
+ * Named constants for the 16 standard ANSI colors.
287
+ *
288
+ * @example
289
+ * ```typescript
290
+ * import { COLORS } from 'blecsd';
291
+ *
292
+ * const fg = COLORS.RED;
293
+ * const bg = COLORS.BLACK;
294
+ * ```
295
+ */
296
+ declare const COLORS: {
297
+ readonly BLACK: Color256;
298
+ readonly MAROON: Color256;
299
+ readonly GREEN: Color256;
300
+ readonly OLIVE: Color256;
301
+ readonly NAVY: Color256;
302
+ readonly PURPLE: Color256;
303
+ readonly TEAL: Color256;
304
+ readonly SILVER: Color256;
305
+ readonly GRAY: Color256;
306
+ readonly RED: Color256;
307
+ readonly LIME: Color256;
308
+ readonly YELLOW: Color256;
309
+ readonly BLUE: Color256;
310
+ readonly FUCHSIA: Color256;
311
+ readonly CYAN: Color256;
312
+ readonly WHITE: Color256;
313
+ };
314
+ /**
315
+ * Alias for standard colors using common terminal names.
316
+ */
317
+ declare const ANSI: {
318
+ readonly DARK_GRAY: Color256;
319
+ readonly LIGHT_GRAY: Color256;
320
+ readonly BRIGHT_RED: Color256;
321
+ readonly BRIGHT_GREEN: Color256;
322
+ readonly BRIGHT_YELLOW: Color256;
323
+ readonly BRIGHT_BLUE: Color256;
324
+ readonly BRIGHT_MAGENTA: Color256;
325
+ readonly BRIGHT_CYAN: Color256;
326
+ readonly MAGENTA: Color256;
327
+ readonly DARK_RED: Color256;
328
+ readonly DARK_GREEN: Color256;
329
+ readonly DARK_YELLOW: Color256;
330
+ readonly DARK_BLUE: Color256;
331
+ readonly DARK_MAGENTA: Color256;
332
+ readonly DARK_CYAN: Color256;
333
+ readonly BLACK: Color256;
334
+ readonly MAROON: Color256;
335
+ readonly GREEN: Color256;
336
+ readonly OLIVE: Color256;
337
+ readonly NAVY: Color256;
338
+ readonly PURPLE: Color256;
339
+ readonly TEAL: Color256;
340
+ readonly SILVER: Color256;
341
+ readonly GRAY: Color256;
342
+ readonly RED: Color256;
343
+ readonly LIME: Color256;
344
+ readonly YELLOW: Color256;
345
+ readonly BLUE: Color256;
346
+ readonly FUCHSIA: Color256;
347
+ readonly CYAN: Color256;
348
+ readonly WHITE: Color256;
349
+ };
350
+
351
+ /**
352
+ * Color format conversion functions
353
+ * @module terminal/colors/convert
354
+ */
355
+
356
+ /**
357
+ * Converts a hex color string to RGB.
358
+ * Supports #RGB, #RRGGBB, and #RRGGBBAA formats.
359
+ *
360
+ * @param hex - Hex color string (e.g., '#ff0000', '#f00', '#ff000080')
361
+ * @returns RGB or RGBA object
362
+ * @throws Error if hex format is invalid
363
+ *
364
+ * @example
365
+ * ```typescript
366
+ * import { hexToRgb } from 'blecsd';
367
+ *
368
+ * hexToRgb('#ff0000'); // { r: 255, g: 0, b: 0 }
369
+ * hexToRgb('#f00'); // { r: 255, g: 0, b: 0 }
370
+ * hexToRgb('#ff000080'); // { r: 255, g: 0, b: 0, a: 0.5 }
371
+ * ```
372
+ */
373
+ declare function hexToRgb(hex: string): RGB | RGBA;
374
+ /**
375
+ * Converts an RGB color to a hex string.
376
+ *
377
+ * @param rgb - RGB color object
378
+ * @returns Hex color string (e.g., '#ff0000')
379
+ *
380
+ * @example
381
+ * ```typescript
382
+ * import { rgbToHex } from 'blecsd';
383
+ *
384
+ * rgbToHex({ r: 255, g: 0, b: 0 }); // '#ff0000'
385
+ * ```
386
+ */
387
+ declare function rgbToHex(rgb: RGB): string;
388
+ /**
389
+ * Converts an RGBA color to a hex string with alpha.
390
+ *
391
+ * @param rgba - RGBA color object
392
+ * @returns Hex color string (e.g., '#ff000080')
393
+ *
394
+ * @example
395
+ * ```typescript
396
+ * import { rgbaToHex } from 'blecsd';
397
+ *
398
+ * rgbaToHex({ r: 255, g: 0, b: 0, a: 0.5 }); // '#ff000080'
399
+ * ```
400
+ */
401
+ declare function rgbaToHex(rgba: RGBA): string;
402
+ /**
403
+ * Converts an RGB color to HSL.
404
+ *
405
+ * @param rgb - RGB color object
406
+ * @returns HSL color object (h: 0-360, s: 0-100, l: 0-100)
407
+ *
408
+ * @example
409
+ * ```typescript
410
+ * import { rgbToHsl } from 'blecsd';
411
+ *
412
+ * rgbToHsl({ r: 255, g: 0, b: 0 }); // { h: 0, s: 100, l: 50 }
413
+ * rgbToHsl({ r: 0, g: 255, b: 0 }); // { h: 120, s: 100, l: 50 }
414
+ * ```
415
+ */
416
+ declare function rgbToHsl(rgb: RGB): HSL;
417
+ /**
418
+ * Converts an HSL color to RGB.
419
+ *
420
+ * @param hsl - HSL color object (h: 0-360, s: 0-100, l: 0-100)
421
+ * @returns RGB color object
422
+ *
423
+ * @example
424
+ * ```typescript
425
+ * import { hslToRgb } from 'blecsd';
426
+ *
427
+ * hslToRgb({ h: 0, s: 100, l: 50 }); // { r: 255, g: 0, b: 0 }
428
+ * hslToRgb({ h: 120, s: 100, l: 50 }); // { r: 0, g: 255, b: 0 }
429
+ * ```
430
+ */
431
+ declare function hslToRgb(hsl: HSL): RGB;
432
+ /**
433
+ * Converts RGBA to HSLA.
434
+ */
435
+ declare function rgbaToHsla(rgba: RGBA): HSLA;
436
+ /**
437
+ * Converts HSLA to RGBA.
438
+ */
439
+ declare function hslaToRgba(hsla: HSLA): RGBA;
440
+ /**
441
+ * Finds the nearest 256-color palette index for an RGB color.
442
+ * Uses Euclidean distance in RGB space for matching.
443
+ *
444
+ * @param rgb - RGB color to match
445
+ * @returns The closest Color256 palette index
446
+ *
447
+ * @example
448
+ * ```typescript
449
+ * import { rgbToColor256 } from 'blecsd';
450
+ *
451
+ * rgbToColor256({ r: 255, g: 0, b: 0 }); // 9 (bright red)
452
+ * rgbToColor256({ r: 128, g: 128, b: 128 }); // 244 (gray)
453
+ * ```
454
+ */
455
+ declare function rgbToColor256(rgb: RGB): Color256;
456
+ /**
457
+ * Converts a 256-color palette index to RGB.
458
+ *
459
+ * @param color - Color256 palette index
460
+ * @returns RGB color object
461
+ *
462
+ * @example
463
+ * ```typescript
464
+ * import { color256ToRgb } from 'blecsd';
465
+ *
466
+ * color256ToRgb(9); // { r: 255, g: 0, b: 0 }
467
+ * color256ToRgb(244); // { r: 168, g: 168, b: 168 }
468
+ * ```
469
+ */
470
+ declare function color256ToRgb(color: Color256): RGB;
471
+ /**
472
+ * Converts a hex color directly to the nearest 256-color index.
473
+ *
474
+ * @param hex - Hex color string
475
+ * @returns Color256 palette index
476
+ *
477
+ * @example
478
+ * ```typescript
479
+ * import { hexToColor256 } from 'blecsd';
480
+ *
481
+ * hexToColor256('#ff0000'); // 9 (bright red)
482
+ * ```
483
+ */
484
+ declare function hexToColor256(hex: string): Color256;
485
+ /**
486
+ * Converts a 256-color palette index to hex.
487
+ *
488
+ * @param color - Color256 palette index
489
+ * @returns Hex color string
490
+ *
491
+ * @example
492
+ * ```typescript
493
+ * import { color256ToHex } from 'blecsd';
494
+ *
495
+ * color256ToHex(9); // '#ff0000'
496
+ * ```
497
+ */
498
+ declare function color256ToHex(color: Color256): string;
499
+ /**
500
+ * Packs an RGB color into a 24-bit integer (0xRRGGBB).
501
+ *
502
+ * @param rgb - RGB color object
503
+ * @returns Packed 24-bit color value
504
+ *
505
+ * @example
506
+ * ```typescript
507
+ * import { rgbToTruecolor } from 'blecsd';
508
+ *
509
+ * rgbToTruecolor({ r: 255, g: 0, b: 0 }); // 0xff0000 (16711680)
510
+ * ```
511
+ */
512
+ declare function rgbToTruecolor(rgb: RGB): number;
513
+ /**
514
+ * Unpacks a 24-bit truecolor integer to RGB.
515
+ *
516
+ * @param color - Packed 24-bit color value (0xRRGGBB)
517
+ * @returns RGB color object
518
+ *
519
+ * @example
520
+ * ```typescript
521
+ * import { truecolorToRgb } from 'blecsd';
522
+ *
523
+ * truecolorToRgb(0xff0000); // { r: 255, g: 0, b: 0 }
524
+ * ```
525
+ */
526
+ declare function truecolorToRgb(color: number): RGB;
527
+ /**
528
+ * Converts a hex color to a 24-bit truecolor integer.
529
+ *
530
+ * @param hex - Hex color string
531
+ * @returns Packed 24-bit color value
532
+ *
533
+ * @example
534
+ * ```typescript
535
+ * import { hexToTruecolor } from 'blecsd';
536
+ *
537
+ * hexToTruecolor('#ff0000'); // 0xff0000
538
+ * ```
539
+ */
540
+ declare function hexToTruecolor(hex: string): number;
541
+ /**
542
+ * Converts a 24-bit truecolor integer to hex.
543
+ *
544
+ * @param color - Packed 24-bit color value
545
+ * @returns Hex color string
546
+ *
547
+ * @example
548
+ * ```typescript
549
+ * import { truecolorToHex } from 'blecsd';
550
+ *
551
+ * truecolorToHex(0xff0000); // '#ff0000'
552
+ * ```
553
+ */
554
+ declare function truecolorToHex(color: number): string;
555
+ /**
556
+ * Converts a truecolor value to the nearest 256-color index.
557
+ * Useful for downgrading colors to terminals that don't support truecolor.
558
+ *
559
+ * @param color - Packed 24-bit color value
560
+ * @returns Color256 palette index
561
+ *
562
+ * @example
563
+ * ```typescript
564
+ * import { truecolorToColor256 } from 'blecsd';
565
+ *
566
+ * truecolorToColor256(0xff0000); // 9 (bright red)
567
+ * ```
568
+ */
569
+ declare function truecolorToColor256(color: number): Color256;
570
+ /**
571
+ * Converts a 256-color palette index to a 24-bit truecolor value.
572
+ *
573
+ * @param color - Color256 palette index
574
+ * @returns Packed 24-bit color value
575
+ *
576
+ * @example
577
+ * ```typescript
578
+ * import { color256ToTruecolor } from 'blecsd';
579
+ *
580
+ * color256ToTruecolor(9); // 0xff0000
581
+ * ```
582
+ */
583
+ declare function color256ToTruecolor(color: Color256): number;
584
+ /**
585
+ * Generates the SGR parameters for a 256-color foreground.
586
+ * Use with ESC[38;5;${n}m
587
+ *
588
+ * @param color - Color256 palette index
589
+ * @returns SGR parameter string (e.g., '38;5;196')
590
+ *
591
+ * @example
592
+ * ```typescript
593
+ * import { sgrFg256 } from 'blecsd';
594
+ *
595
+ * const params = sgrFg256(196);
596
+ * const escape = `\x1b[${params}m`; // '\x1b[38;5;196m'
597
+ * ```
598
+ */
599
+ declare function sgrFg256(color: Color256): string;
600
+ /**
601
+ * Generates the SGR parameters for a 256-color background.
602
+ * Use with ESC[48;5;${n}m
603
+ *
604
+ * @param color - Color256 palette index
605
+ * @returns SGR parameter string (e.g., '48;5;196')
606
+ */
607
+ declare function sgrBg256(color: Color256): string;
608
+ /**
609
+ * Generates the SGR parameters for a truecolor foreground.
610
+ * Use with ESC[38;2;r;g;b m
611
+ *
612
+ * @param rgb - RGB color object or packed truecolor
613
+ * @returns SGR parameter string (e.g., '38;2;255;0;0')
614
+ *
615
+ * @example
616
+ * ```typescript
617
+ * import { sgrFgRgb } from 'blecsd';
618
+ *
619
+ * const params = sgrFgRgb({ r: 255, g: 0, b: 0 });
620
+ * const escape = `\x1b[${params}m`; // '\x1b[38;2;255;0;0m'
621
+ * ```
622
+ */
623
+ declare function sgrFgRgb(rgb: RGB | number): string;
624
+ /**
625
+ * Generates the SGR parameters for a truecolor background.
626
+ * Use with ESC[48;2;r;g;b m
627
+ *
628
+ * @param rgb - RGB color object or packed truecolor
629
+ * @returns SGR parameter string (e.g., '48;2;255;0;0')
630
+ */
631
+ declare function sgrBgRgb(rgb: RGB | number): string;
632
+ /**
633
+ * Converts RGB directly to the nearest color cube index (16-231).
634
+ * More efficient than searching the full palette when you know
635
+ * you want a color cube match.
636
+ *
637
+ * @param rgb - RGB color object
638
+ * @returns Color256 index in the color cube range
639
+ *
640
+ * @example
641
+ * ```typescript
642
+ * import { rgbToColorCube } from 'blecsd';
643
+ *
644
+ * rgbToColorCube({ r: 255, g: 0, b: 0 }); // 196
645
+ * ```
646
+ */
647
+ declare function rgbToColorCube(rgb: RGB): Color256;
648
+ /**
649
+ * Converts RGB directly to the nearest grayscale index (232-255).
650
+ * More efficient than searching when you want a grayscale match.
651
+ *
652
+ * @param rgb - RGB color object
653
+ * @returns Color256 index in the grayscale range
654
+ *
655
+ * @example
656
+ * ```typescript
657
+ * import { rgbToGrayscale256 } from 'blecsd';
658
+ *
659
+ * rgbToGrayscale256({ r: 128, g: 128, b: 128 }); // ~244
660
+ * ```
661
+ */
662
+ declare function rgbToGrayscale256(rgb: RGB): Color256;
663
+ /**
664
+ * Unified color value type that can represent any color format.
665
+ */
666
+ type ColorValue = string | number | RGB | Color256;
667
+ /**
668
+ * Parses any color value into RGB.
669
+ *
670
+ * @param value - Color in any supported format:
671
+ * - Hex string: '#ff0000', '#f00'
672
+ * - RGB object: { r: 255, g: 0, b: 0 }
673
+ * - 256-color index: 9 (if 0-255)
674
+ * - Truecolor integer: 0xff0000 (if > 255)
675
+ *
676
+ * @returns RGB color object
677
+ * @throws Error if format is not recognized
678
+ *
679
+ * @example
680
+ * ```typescript
681
+ * import { parseColor } from 'blecsd';
682
+ *
683
+ * parseColor('#ff0000'); // { r: 255, g: 0, b: 0 }
684
+ * parseColor({ r: 255, g: 0, b: 0 }); // { r: 255, g: 0, b: 0 }
685
+ * parseColor(9); // { r: 255, g: 0, b: 0 } (256-color)
686
+ * parseColor(0xff0000); // { r: 255, g: 0, b: 0 } (truecolor)
687
+ * ```
688
+ */
689
+ declare function parseColor(value: ColorValue): RGB;
690
+ /**
691
+ * Converts any color value to the nearest 256-color index.
692
+ *
693
+ * @param value - Color in any supported format
694
+ * @returns Color256 palette index
695
+ *
696
+ * @example
697
+ * ```typescript
698
+ * import { toColor256 } from 'blecsd';
699
+ *
700
+ * toColor256('#ff0000'); // 9
701
+ * toColor256({ r: 255, g: 0, b: 0 }); // 9
702
+ * toColor256(0xff0000); // 9
703
+ * ```
704
+ */
705
+ declare function toColor256(value: ColorValue): Color256;
706
+ /**
707
+ * Converts any color value to a 24-bit truecolor integer.
708
+ *
709
+ * @param value - Color in any supported format
710
+ * @returns Packed 24-bit color value
711
+ *
712
+ * @example
713
+ * ```typescript
714
+ * import { toTruecolor } from 'blecsd';
715
+ *
716
+ * toTruecolor('#ff0000'); // 0xff0000
717
+ * toTruecolor({ r: 255, g: 0, b: 0 }); // 0xff0000
718
+ * toTruecolor(9); // 0xff0000
719
+ * ```
720
+ */
721
+ declare function toTruecolor(value: ColorValue): number;
722
+ /**
723
+ * Converts any color value to a hex string.
724
+ *
725
+ * @param value - Color in any supported format
726
+ * @returns Hex color string
727
+ *
728
+ * @example
729
+ * ```typescript
730
+ * import { toHex } from 'blecsd';
731
+ *
732
+ * toHex({ r: 255, g: 0, b: 0 }); // '#ff0000'
733
+ * toHex(9); // '#ff0000'
734
+ * toHex(0xff0000); // '#ff0000'
735
+ * ```
736
+ */
737
+ declare function toHex(value: ColorValue): string;
738
+
739
+ /**
740
+ * Color name mappings for terminal colors
741
+ * @module terminal/colors/names
742
+ */
743
+
744
+ /**
745
+ * Basic terminal color names (standard ANSI).
746
+ */
747
+ type BasicColorName = 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white';
748
+ /**
749
+ * Light/bright color variants.
750
+ */
751
+ type LightColorName = 'lightblack' | 'lightred' | 'lightgreen' | 'lightyellow' | 'lightblue' | 'lightmagenta' | 'lightcyan' | 'lightwhite';
752
+ /**
753
+ * Bright color aliases (alternative naming).
754
+ */
755
+ type BrightColorName = 'brightblack' | 'brightred' | 'brightgreen' | 'brightyellow' | 'brightblue' | 'brightmagenta' | 'brightcyan' | 'brightwhite';
756
+ /**
757
+ * Dark color variants.
758
+ */
759
+ type DarkColorName = 'darkred' | 'darkgreen' | 'darkyellow' | 'darkblue' | 'darkmagenta' | 'darkcyan' | 'darkgray' | 'darkgrey';
760
+ /**
761
+ * Special color names.
762
+ */
763
+ type SpecialColorName = 'default' | 'transparent' | 'inherit';
764
+ /**
765
+ * All supported color names.
766
+ */
767
+ type ColorName = BasicColorName | LightColorName | BrightColorName | DarkColorName | SpecialColorName | 'gray' | 'grey' | 'silver' | 'maroon' | 'olive' | 'navy' | 'purple' | 'teal' | 'aqua' | 'lime' | 'fuchsia' | 'orange';
768
+ /**
769
+ * Mapping of color names to 256-color palette indices.
770
+ */
771
+ declare const COLOR_NAMES: Record<string, Color256>;
772
+ /**
773
+ * Color aliases mapping common alternate names to canonical names.
774
+ */
775
+ declare const COLOR_ALIASES: Record<string, string>;
776
+ /**
777
+ * Schema for validating color names.
778
+ *
779
+ * @example
780
+ * ```typescript
781
+ * import { ColorNameSchema } from 'blecsd';
782
+ *
783
+ * const result = ColorNameSchema.safeParse('red');
784
+ * if (result.success) {
785
+ * console.log('Valid color name');
786
+ * }
787
+ * ```
788
+ */
789
+ declare const ColorNameSchema: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
790
+ /**
791
+ * Converts a color name to a Color256 index.
792
+ * Returns null if the name is not recognized or is a special value.
793
+ *
794
+ * @param name - The color name (case-insensitive)
795
+ * @returns Color256 index or null
796
+ *
797
+ * @example
798
+ * ```typescript
799
+ * import { nameToColor } from 'blecsd';
800
+ *
801
+ * nameToColor('red'); // 1
802
+ * nameToColor('brightred'); // 9
803
+ * nameToColor('invalid'); // null
804
+ * nameToColor('default'); // null (special value)
805
+ * ```
806
+ */
807
+ declare function nameToColor(name: string): Color256 | null;
808
+ /**
809
+ * Converts a Color256 index to a canonical color name.
810
+ * Returns null for colors without standard names.
811
+ *
812
+ * @param color - The Color256 index
813
+ * @returns Color name or null
814
+ *
815
+ * @example
816
+ * ```typescript
817
+ * import { colorToName } from 'blecsd';
818
+ *
819
+ * colorToName(1); // 'red'
820
+ * colorToName(9); // 'brightred'
821
+ * colorToName(100); // null (no standard name)
822
+ * ```
823
+ */
824
+ declare function colorToName(color: Color256): string | null;
825
+ /**
826
+ * Checks if a string is a valid color name.
827
+ *
828
+ * @param name - The string to check
829
+ * @returns True if valid color name
830
+ *
831
+ * @example
832
+ * ```typescript
833
+ * import { isColorName } from 'blecsd';
834
+ *
835
+ * isColorName('red'); // true
836
+ * isColorName('invalid'); // false
837
+ * ```
838
+ */
839
+ declare function isColorName(name: string): name is ColorName;
840
+ /**
841
+ * Checks if a color name is a special value (default, transparent, inherit).
842
+ *
843
+ * @param name - The color name
844
+ * @returns True if special value
845
+ *
846
+ * @example
847
+ * ```typescript
848
+ * import { isSpecialColor } from 'blecsd';
849
+ *
850
+ * isSpecialColor('default'); // true
851
+ * isSpecialColor('transparent'); // true
852
+ * isSpecialColor('red'); // false
853
+ * ```
854
+ */
855
+ declare function isSpecialColor(name: string): name is SpecialColorName;
856
+ /**
857
+ * Extended CSS/X11 color names with RGB values.
858
+ * These are matched to the nearest 256-color palette entry.
859
+ */
860
+ declare const CSS_COLORS: Record<string, RGB>;
861
+ /**
862
+ * Converts a CSS/X11 color name to the nearest Color256 index.
863
+ * Returns null if the name is not recognized.
864
+ *
865
+ * @param name - The CSS color name (case-insensitive)
866
+ * @returns Color256 index or null
867
+ *
868
+ * @example
869
+ * ```typescript
870
+ * import { cssNameToColor } from 'blecsd';
871
+ *
872
+ * cssNameToColor('coral'); // Nearest 256-color match
873
+ * cssNameToColor('invalid'); // null
874
+ * ```
875
+ */
876
+ declare function cssNameToColor(name: string): Color256 | null;
877
+ /**
878
+ * Gets all available color names.
879
+ *
880
+ * @returns Array of color name strings
881
+ *
882
+ * @example
883
+ * ```typescript
884
+ * import { getColorNames } from 'blecsd';
885
+ *
886
+ * const names = getColorNames();
887
+ * // ['black', 'red', 'green', ...]
888
+ * ```
889
+ */
890
+ declare function getColorNames(): readonly string[];
891
+ /**
892
+ * Gets all available CSS/X11 color names.
893
+ *
894
+ * @returns Array of CSS color name strings
895
+ */
896
+ declare function getCssColorNames(): readonly string[];
897
+
898
+ /**
899
+ * Color blending and mixing functions
900
+ * @module terminal/colors/blend
901
+ */
902
+
903
+ /**
904
+ * Mixes two RGB colors together.
905
+ *
906
+ * @param c1 - First color
907
+ * @param c2 - Second color
908
+ * @param ratio - Blend ratio (0 = all c1, 1 = all c2, 0.5 = equal mix). Default 0.5
909
+ * @returns Blended RGB color
910
+ *
911
+ * @example
912
+ * ```typescript
913
+ * import { mix } from 'blecsd';
914
+ *
915
+ * // 50/50 mix of red and blue
916
+ * const purple = mix(
917
+ * { r: 255, g: 0, b: 0 },
918
+ * { r: 0, g: 0, b: 255 }
919
+ * );
920
+ *
921
+ * // 75% red, 25% blue
922
+ * const redPurple = mix(
923
+ * { r: 255, g: 0, b: 0 },
924
+ * { r: 0, g: 0, b: 255 },
925
+ * 0.25
926
+ * );
927
+ * ```
928
+ */
929
+ declare function mix(c1: RGB, c2: RGB, ratio?: number): RGB;
930
+ /**
931
+ * Blends two Color256 palette colors together.
932
+ *
933
+ * @param c1 - First palette color
934
+ * @param c2 - Second palette color
935
+ * @param ratio - Blend ratio (0 = all c1, 1 = all c2). Default 0.5
936
+ * @returns Nearest Color256 to the blended result
937
+ *
938
+ * @example
939
+ * ```typescript
940
+ * import { blend, COLORS } from 'blecsd';
941
+ *
942
+ * // Mix red and blue
943
+ * const purple = blend(COLORS.RED, COLORS.BLUE);
944
+ * ```
945
+ */
946
+ declare function blend(c1: Color256, c2: Color256, ratio?: number): Color256;
947
+ /**
948
+ * Lightens an RGB color by a percentage.
949
+ *
950
+ * @param color - The color to lighten
951
+ * @param amount - Amount to lighten (0-1, where 1 = white)
952
+ * @returns Lightened RGB color
953
+ *
954
+ * @example
955
+ * ```typescript
956
+ * import { lighten } from 'blecsd';
957
+ *
958
+ * const lightRed = lighten({ r: 255, g: 0, b: 0 }, 0.3);
959
+ * ```
960
+ */
961
+ declare function lighten(color: RGB, amount: number): RGB;
962
+ /**
963
+ * Darkens an RGB color by a percentage.
964
+ *
965
+ * @param color - The color to darken
966
+ * @param amount - Amount to darken (0-1, where 1 = black)
967
+ * @returns Darkened RGB color
968
+ *
969
+ * @example
970
+ * ```typescript
971
+ * import { darken } from 'blecsd';
972
+ *
973
+ * const darkRed = darken({ r: 255, g: 0, b: 0 }, 0.3);
974
+ * ```
975
+ */
976
+ declare function darken(color: RGB, amount: number): RGB;
977
+ /**
978
+ * Lightens a Color256 palette color.
979
+ *
980
+ * @param color - The palette color
981
+ * @param amount - Amount to lighten (0-1)
982
+ * @returns Nearest Color256 to the lightened result
983
+ */
984
+ declare function lighten256(color: Color256, amount: number): Color256;
985
+ /**
986
+ * Darkens a Color256 palette color.
987
+ *
988
+ * @param color - The palette color
989
+ * @param amount - Amount to darken (0-1)
990
+ * @returns Nearest Color256 to the darkened result
991
+ */
992
+ declare function darken256(color: Color256, amount: number): Color256;
993
+ /**
994
+ * Increases the saturation of an RGB color.
995
+ *
996
+ * @param color - The color to saturate
997
+ * @param amount - Amount to increase saturation (0-1)
998
+ * @returns Saturated RGB color
999
+ *
1000
+ * @example
1001
+ * ```typescript
1002
+ * import { saturate } from 'blecsd';
1003
+ *
1004
+ * // Make a muted color more vibrant
1005
+ * const vibrant = saturate({ r: 180, g: 150, b: 150 }, 0.5);
1006
+ * ```
1007
+ */
1008
+ declare function saturate(color: RGB, amount: number): RGB;
1009
+ /**
1010
+ * Decreases the saturation of an RGB color.
1011
+ *
1012
+ * @param color - The color to desaturate
1013
+ * @param amount - Amount to decrease saturation (0-1, where 1 = grayscale)
1014
+ * @returns Desaturated RGB color
1015
+ *
1016
+ * @example
1017
+ * ```typescript
1018
+ * import { desaturate } from 'blecsd';
1019
+ *
1020
+ * // Make a color more muted
1021
+ * const muted = desaturate({ r: 255, g: 0, b: 0 }, 0.5);
1022
+ *
1023
+ * // Full desaturation = grayscale
1024
+ * const gray = desaturate({ r: 255, g: 0, b: 0 }, 1);
1025
+ * ```
1026
+ */
1027
+ declare function desaturate(color: RGB, amount: number): RGB;
1028
+ /**
1029
+ * Converts an RGB color to grayscale.
1030
+ *
1031
+ * @param color - The color to convert
1032
+ * @returns Grayscale RGB color
1033
+ *
1034
+ * @example
1035
+ * ```typescript
1036
+ * import { grayscale } from 'blecsd';
1037
+ *
1038
+ * const gray = grayscale({ r: 255, g: 0, b: 0 }); // { r: 77, g: 77, b: 77 }
1039
+ * ```
1040
+ */
1041
+ declare function grayscale(color: RGB): RGB;
1042
+ /**
1043
+ * Blends a foreground color with alpha over a background color.
1044
+ * Uses standard alpha compositing (Porter-Duff over operator).
1045
+ *
1046
+ * @param fg - Foreground color with alpha
1047
+ * @param bg - Background color (assumed opaque)
1048
+ * @returns Composited RGB color
1049
+ *
1050
+ * @example
1051
+ * ```typescript
1052
+ * import { blendWithAlpha } from 'blecsd';
1053
+ *
1054
+ * // 50% transparent red over blue
1055
+ * const result = blendWithAlpha(
1056
+ * { r: 255, g: 0, b: 0, a: 0.5 },
1057
+ * { r: 0, g: 0, b: 255 }
1058
+ * );
1059
+ * // { r: 128, g: 0, b: 128 }
1060
+ * ```
1061
+ */
1062
+ declare function blendWithAlpha(fg: RGBA, bg: RGB): RGB;
1063
+ /**
1064
+ * Blends two colors with alpha values together.
1065
+ * Uses Porter-Duff source over destination.
1066
+ *
1067
+ * @param src - Source (foreground) color
1068
+ * @param dst - Destination (background) color
1069
+ * @returns Composited RGBA color
1070
+ *
1071
+ * @example
1072
+ * ```typescript
1073
+ * import { blendAlpha } from 'blecsd';
1074
+ *
1075
+ * const result = blendAlpha(
1076
+ * { r: 255, g: 0, b: 0, a: 0.5 },
1077
+ * { r: 0, g: 0, b: 255, a: 0.5 }
1078
+ * );
1079
+ * ```
1080
+ */
1081
+ declare function blendAlpha(src: RGBA, dst: RGBA): RGBA;
1082
+ /**
1083
+ * Rotates the hue of a color.
1084
+ *
1085
+ * @param color - The color to modify
1086
+ * @param degrees - Degrees to rotate hue (0-360)
1087
+ * @returns Color with rotated hue
1088
+ *
1089
+ * @example
1090
+ * ```typescript
1091
+ * import { rotateHue } from 'blecsd';
1092
+ *
1093
+ * // Red rotated 120 degrees = green
1094
+ * const green = rotateHue({ r: 255, g: 0, b: 0 }, 120);
1095
+ * ```
1096
+ */
1097
+ declare function rotateHue(color: RGB, degrees: number): RGB;
1098
+ /**
1099
+ * Gets the complementary color (hue + 180 degrees).
1100
+ *
1101
+ * @param color - The original color
1102
+ * @returns Complementary RGB color
1103
+ *
1104
+ * @example
1105
+ * ```typescript
1106
+ * import { complement } from 'blecsd';
1107
+ *
1108
+ * const cyan = complement({ r: 255, g: 0, b: 0 }); // Complement of red
1109
+ * ```
1110
+ */
1111
+ declare function complement(color: RGB): RGB;
1112
+ /**
1113
+ * Inverts a color (255 - each channel).
1114
+ *
1115
+ * @param color - The color to invert
1116
+ * @returns Inverted RGB color
1117
+ *
1118
+ * @example
1119
+ * ```typescript
1120
+ * import { invert } from 'blecsd';
1121
+ *
1122
+ * const cyan = invert({ r: 255, g: 0, b: 0 }); // { r: 0, g: 255, b: 255 }
1123
+ * ```
1124
+ */
1125
+ declare function invert(color: RGB): RGB;
1126
+ /**
1127
+ * Generates a gradient of colors between two endpoints.
1128
+ *
1129
+ * @param from - Starting color
1130
+ * @param to - Ending color
1131
+ * @param steps - Number of colors to generate (including endpoints)
1132
+ * @returns Array of RGB colors forming the gradient
1133
+ *
1134
+ * @example
1135
+ * ```typescript
1136
+ * import { gradient } from 'blecsd';
1137
+ *
1138
+ * // 5-step gradient from red to blue
1139
+ * const colors = gradient(
1140
+ * { r: 255, g: 0, b: 0 },
1141
+ * { r: 0, g: 0, b: 255 },
1142
+ * 5
1143
+ * );
1144
+ * // [red, redPurple, purple, bluePurple, blue]
1145
+ * ```
1146
+ */
1147
+ declare function gradient(from: RGB, to: RGB, steps: number): RGB[];
1148
+ /**
1149
+ * Generates a gradient using Color256 palette colors.
1150
+ *
1151
+ * @param from - Starting palette color
1152
+ * @param to - Ending palette color
1153
+ * @param steps - Number of colors to generate
1154
+ * @returns Array of Color256 values forming the gradient
1155
+ *
1156
+ * @example
1157
+ * ```typescript
1158
+ * import { gradient256, COLORS } from 'blecsd';
1159
+ *
1160
+ * const colors = gradient256(COLORS.RED, COLORS.BLUE, 5);
1161
+ * ```
1162
+ */
1163
+ declare function gradient256(from: Color256, to: Color256, steps: number): Color256[];
1164
+ /**
1165
+ * Calculates the relative luminance of a color (0-1).
1166
+ * Used for calculating contrast ratios.
1167
+ *
1168
+ * @param color - The color
1169
+ * @returns Relative luminance (0-1)
1170
+ */
1171
+ declare function luminance(color: RGB): number;
1172
+ /**
1173
+ * Calculates the contrast ratio between two colors.
1174
+ * Result is between 1 (no contrast) and 21 (maximum contrast).
1175
+ *
1176
+ * WCAG guidelines:
1177
+ * - 4.5:1 minimum for normal text
1178
+ * - 3:1 minimum for large text
1179
+ * - 7:1 enhanced for normal text
1180
+ *
1181
+ * @param c1 - First color
1182
+ * @param c2 - Second color
1183
+ * @returns Contrast ratio (1-21)
1184
+ *
1185
+ * @example
1186
+ * ```typescript
1187
+ * import { contrastRatio } from 'blecsd';
1188
+ *
1189
+ * const ratio = contrastRatio(
1190
+ * { r: 0, g: 0, b: 0 },
1191
+ * { r: 255, g: 255, b: 255 }
1192
+ * ); // 21 (maximum contrast)
1193
+ * ```
1194
+ */
1195
+ declare function contrastRatio(c1: RGB, c2: RGB): number;
1196
+ /**
1197
+ * Determines if two colors have sufficient contrast for accessibility.
1198
+ *
1199
+ * @param c1 - First color
1200
+ * @param c2 - Second color
1201
+ * @param threshold - Minimum contrast ratio (default: 4.5 for WCAG AA)
1202
+ * @returns True if contrast is sufficient
1203
+ *
1204
+ * @example
1205
+ * ```typescript
1206
+ * import { isReadable } from 'blecsd';
1207
+ *
1208
+ * if (isReadable(textColor, backgroundColor)) {
1209
+ * // Text is readable
1210
+ * }
1211
+ * ```
1212
+ */
1213
+ declare function isReadable(c1: RGB, c2: RGB, threshold?: number): boolean;
1214
+
1215
+ export { nameToColor as $, desaturate as A, type BasicColorName as B, COLOR_ALIASES as C, type DarkColorName as D, getColorNames as E, getCssColorNames as F, gradient as G, type HSL as H, gradient256 as I, grayscale as J, hexToColor256 as K, type LightColorName as L, hexToRgb as M, hslToRgb as N, hslaToRgba as O, invert as P, isColor256 as Q, type RGB as R, type SpecialColorName as S, isColorName as T, isRGB as U, isReadable as V, isSpecialColor as W, lighten as X, lighten256 as Y, luminance as Z, mix as _, type BrightColorName as a, rgbToColor256 as a0, rgbToHex as a1, rgbToHsl as a2, rgbaToHex as a3, rgbaToHsla as a4, rotateHue as a5, saturate as a6, ANSI as a7, COLORS as a8, COLOR_CUBE_LEVELS as a9, PALETTE_HEX as aa, PALETTE_RGB as ab, asColor256 as ac, color256ToTruecolor as ad, colorCubeIndex as ae, getHex as af, getRGB as ag, grayscaleIndex as ah, hexToTruecolor as ai, isColorCube as aj, isGrayscale as ak, isStandardColor as al, parseColor as am, rgbToColorCube as an, rgbToGrayscale256 as ao, rgbToTruecolor as ap, sgrBg256 as aq, sgrBgRgb as ar, sgrFg256 as as, sgrFgRgb as at, toColor256 as au, toHex as av, toTruecolor as aw, truecolorToColor256 as ax, truecolorToHex as ay, truecolorToRgb as az, COLOR_NAMES as b, CSS_COLORS as c, type Color256 as d, Color256Schema as e, type ColorName as f, ColorNameSchema as g, type ColorValue as h, type HSLA as i, HSLASchema as j, HSLSchema as k, HexColorSchema as l, type RGBA as m, RGBASchema as n, RGBSchema as o, blend as p, blendAlpha as q, blendWithAlpha as r, color256ToHex as s, color256ToRgb as t, colorToName as u, complement as v, contrastRatio as w, cssNameToColor as x, darken as y, darken256 as z };