gradients.d.ts 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. import type { Color3 } from "../Maths/math.color";
  2. import { Color4 } from "../Maths/math.color";
  3. /** Interface used by value gradients (color, factor, ...) */
  4. export interface IValueGradient {
  5. /**
  6. * Gets or sets the gradient value (between 0 and 1)
  7. */
  8. gradient: number;
  9. }
  10. /** Class used to store color4 gradient */
  11. export declare class ColorGradient implements IValueGradient {
  12. /**
  13. * Gets or sets the gradient value (between 0 and 1)
  14. */
  15. gradient: number;
  16. /**
  17. * Gets or sets first associated color
  18. */
  19. color1: Color4;
  20. /**
  21. * Gets or sets second associated color
  22. */
  23. color2?: Color4 | undefined;
  24. /**
  25. * Creates a new color4 gradient
  26. * @param gradient gets or sets the gradient value (between 0 and 1)
  27. * @param color1 gets or sets first associated color
  28. * @param color2 gets or sets first second color
  29. */
  30. constructor(
  31. /**
  32. * Gets or sets the gradient value (between 0 and 1)
  33. */
  34. gradient: number,
  35. /**
  36. * Gets or sets first associated color
  37. */
  38. color1: Color4,
  39. /**
  40. * Gets or sets second associated color
  41. */
  42. color2?: Color4 | undefined);
  43. /**
  44. * Will get a color picked randomly between color1 and color2.
  45. * If color2 is undefined then color1 will be used
  46. * @param result defines the target Color4 to store the result in
  47. */
  48. getColorToRef(result: Color4): void;
  49. }
  50. /** Class used to store color 3 gradient */
  51. export declare class Color3Gradient implements IValueGradient {
  52. /**
  53. * Gets or sets the gradient value (between 0 and 1)
  54. */
  55. gradient: number;
  56. /**
  57. * Gets or sets the associated color
  58. */
  59. color: Color3;
  60. /**
  61. * Creates a new color3 gradient
  62. * @param gradient gets or sets the gradient value (between 0 and 1)
  63. * @param color gets or sets associated color
  64. */
  65. constructor(
  66. /**
  67. * Gets or sets the gradient value (between 0 and 1)
  68. */
  69. gradient: number,
  70. /**
  71. * Gets or sets the associated color
  72. */
  73. color: Color3);
  74. }
  75. /** Class used to store factor gradient */
  76. export declare class FactorGradient implements IValueGradient {
  77. /**
  78. * Gets or sets the gradient value (between 0 and 1)
  79. */
  80. gradient: number;
  81. /**
  82. * Gets or sets first associated factor
  83. */
  84. factor1: number;
  85. /**
  86. * Gets or sets second associated factor
  87. */
  88. factor2?: number | undefined;
  89. /**
  90. * Creates a new factor gradient
  91. * @param gradient gets or sets the gradient value (between 0 and 1)
  92. * @param factor1 gets or sets first associated factor
  93. * @param factor2 gets or sets second associated factor
  94. */
  95. constructor(
  96. /**
  97. * Gets or sets the gradient value (between 0 and 1)
  98. */
  99. gradient: number,
  100. /**
  101. * Gets or sets first associated factor
  102. */
  103. factor1: number,
  104. /**
  105. * Gets or sets second associated factor
  106. */
  107. factor2?: number | undefined);
  108. /**
  109. * Will get a number picked randomly between factor1 and factor2.
  110. * If factor2 is undefined then factor1 will be used
  111. * @returns the picked number
  112. */
  113. getFactor(): number;
  114. }
  115. /**
  116. * Helper used to simplify some generic gradient tasks
  117. */
  118. export declare class GradientHelper {
  119. /**
  120. * Gets the current gradient from an array of IValueGradient
  121. * @param ratio defines the current ratio to get
  122. * @param gradients defines the array of IValueGradient
  123. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  124. */
  125. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  126. }