57e09c4c594f065c15031c2bf103ca622f07acea52ac53218242f03f5b986817ebcbe700fe43482662b286d081ed4fbbeafdb7d1d03e8fa18763f18510d102 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import { HSL, HSV, Numberify, RGB } from './interfaces.js';
  2. /**
  3. * Handle bounds / percentage checking to conform to CSS color spec
  4. * <http://www.w3.org/TR/css3-color/>
  5. * *Assumes:* r, g, b in [0, 255] or [0, 1]
  6. * *Returns:* { r, g, b } in [0, 255]
  7. */
  8. export declare function rgbToRgb(r: number | string, g: number | string, b: number | string): Numberify<RGB>;
  9. /**
  10. * Converts an RGB color value to HSL.
  11. * *Assumes:* r, g, and b are contained in [0, 255] or [0, 1]
  12. * *Returns:* { h, s, l } in [0,1]
  13. */
  14. export declare function rgbToHsl(r: number, g: number, b: number): Numberify<HSL>;
  15. /**
  16. * Converts an HSL color value to RGB.
  17. *
  18. * *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]
  19. * *Returns:* { r, g, b } in the set [0, 255]
  20. */
  21. export declare function hslToRgb(h: number | string, s: number | string, l: number | string): Numberify<RGB>;
  22. /**
  23. * Converts an RGB color value to HSV
  24. *
  25. * *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]
  26. * *Returns:* { h, s, v } in [0,1]
  27. */
  28. export declare function rgbToHsv(r: number, g: number, b: number): Numberify<HSV>;
  29. /**
  30. * Converts an HSV color value to RGB.
  31. *
  32. * *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]
  33. * *Returns:* { r, g, b } in the set [0, 255]
  34. */
  35. export declare function hsvToRgb(h: number | string, s: number | string, v: number | string): Numberify<RGB>;
  36. /**
  37. * Converts an RGB color to hex
  38. *
  39. * Assumes r, g, and b are contained in the set [0, 255]
  40. * Returns a 3 or 6 character hex
  41. */
  42. export declare function rgbToHex(r: number, g: number, b: number, allow3Char: boolean): string;
  43. /**
  44. * Converts an RGBA color plus alpha transparency to hex
  45. *
  46. * Assumes r, g, b are contained in the set [0, 255] and
  47. * a in [0, 1]. Returns a 4 or 8 character rgba hex
  48. */
  49. export declare function rgbaToHex(r: number, g: number, b: number, a: number, allow4Char: boolean): string;
  50. /**
  51. * Converts an RGBA color to an ARGB Hex8 string
  52. * Rarely used, but required for "toFilter()"
  53. */
  54. export declare function rgbaToArgbHex(r: number, g: number, b: number, a: number): string;
  55. /** Converts a decimal to a hex value */
  56. export declare function convertDecimalToHex(d: string | number): string;
  57. /** Converts a hex value to a decimal */
  58. export declare function convertHexToDecimal(h: string): number;
  59. /** Parse a base-16 hex value into a base-10 integer */
  60. export declare function parseIntFromHex(val: string): number;
  61. export declare function numberInputToObject(color: number): RGB;