PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

98 lines
4.6KB

  1. #ifndef __INC_NOISE_H
  2. #define __INC_NOISE_H
  3. #include "FastLED.h"
  4. FASTLED_NAMESPACE_BEGIN
  5. ///@file noise.h
  6. /// Noise functions provided by the library.
  7. ///@defgroup Noise Noise functions
  8. ///Simplex noise function definitions
  9. ///@{
  10. /// @name scaled 16 bit noise functions
  11. ///@{
  12. /// 16 bit, fixed point implementation of perlin's Simplex Noise. Coordinates are
  13. /// 16.16 fixed point values, 32 bit integers with integral coordinates in the high 16
  14. /// bits and fractional in the low 16 bits, and the function takes 1d, 2d, and 3d coordinate
  15. /// values. These functions are scaled to return 0-65535
  16. extern uint16_t inoise16(uint32_t x, uint32_t y, uint32_t z);
  17. extern uint16_t inoise16(uint32_t x, uint32_t y);
  18. extern uint16_t inoise16(uint32_t x);
  19. ///@}
  20. /// @name raw 16 bit noise functions
  21. //@{
  22. /// 16 bit raw versions of the noise functions. These values are not scaled/altered and have
  23. /// output values roughly in the range (-18k,18k)
  24. extern int16_t inoise16_raw(uint32_t x, uint32_t y, uint32_t z);
  25. extern int16_t inoise16_raw(uint32_t x, uint32_t y);
  26. extern int16_t inoise16_raw(uint32_t x);
  27. ///@}
  28. /// @name 8 bit scaled noise functions
  29. ///@{
  30. /// 8 bit, fixed point implementation of perlin's Simplex Noise. Coordinates are
  31. /// 8.8 fixed point values, 16 bit integers with integral coordinates in the high 8
  32. /// bits and fractional in the low 8 bits, and the function takes 1d, 2d, and 3d coordinate
  33. /// values. These functions are scaled to return 0-255
  34. extern uint8_t inoise8(uint16_t x, uint16_t y, uint16_t z);
  35. extern uint8_t inoise8(uint16_t x, uint16_t y);
  36. extern uint8_t inoise8(uint16_t x);
  37. ///@}
  38. /// @name 8 bit raw noise functions
  39. ///@{
  40. /// 8 bit raw versions of the noise functions. These values are not scaled/altered and have
  41. /// output values roughly in the range (-70,70)
  42. extern int8_t inoise8_raw(uint16_t x, uint16_t y, uint16_t z);
  43. extern int8_t inoise8_raw(uint16_t x, uint16_t y);
  44. extern int8_t inoise8_raw(uint16_t x);
  45. ///@}
  46. ///@name raw fill functions
  47. ///@{
  48. /// Raw noise fill functions - fill into a 1d or 2d array of 8-bit values using either 8-bit noise or 16-bit noise
  49. /// functions.
  50. ///@param pData the array of data to write into
  51. ///@param num_points the number of points of noise to compute
  52. ///@param octaves the number of octaves to use for noise
  53. ///@param x the x position in the noise field
  54. ///@param y the y position in the noise field for 2d functions
  55. ///@param scalex the scale (distance) between x points when filling in noise
  56. ///@param scaley the scale (distance) between y points when filling in noise
  57. ///@param time the time position for the noise field
  58. void fill_raw_noise8(uint8_t *pData, uint8_t num_points, uint8_t octaves, uint16_t x, int scalex, uint16_t time);
  59. void fill_raw_noise16into8(uint8_t *pData, uint8_t num_points, uint8_t octaves, uint32_t x, int scalex, uint32_t time);
  60. void fill_raw_2dnoise8(uint8_t *pData, int width, int height, uint8_t octaves, uint16_t x, int scalex, uint16_t y, int scaley, uint16_t time);
  61. void fill_raw_2dnoise16into8(uint8_t *pData, int width, int height, uint8_t octaves, uint32_t x, int scalex, uint32_t y, int scaley, uint32_t time);
  62. void fill_raw_2dnoise16(uint16_t *pData, int width, int height, uint8_t octaves, q88 freq88, fract16 amplitude, int skip, uint32_t x, int scalex, uint32_t y, int scaley, uint32_t time);
  63. void fill_raw_2dnoise16into8(uint8_t *pData, int width, int height, uint8_t octaves, q44 freq44, fract8 amplitude, int skip, uint32_t x, int scalex, uint32_t y, int scaley, uint32_t time);
  64. ///@}
  65. ///@name fill functions
  66. ///@{
  67. /// fill functions to fill leds with values based on noise functions. These functions use the fill_raw_* functions as appropriate.
  68. void fill_noise8(CRGB *leds, int num_leds,
  69. uint8_t octaves, uint16_t x, int scale,
  70. uint8_t hue_octaves, uint16_t hue_x, int hue_scale,
  71. uint16_t time);
  72. void fill_noise16(CRGB *leds, int num_leds,
  73. uint8_t octaves, uint16_t x, int scale,
  74. uint8_t hue_octaves, uint16_t hue_x, int hue_scale,
  75. uint16_t time, uint8_t hue_shift=0);
  76. void fill_2dnoise8(CRGB *leds, int width, int height, bool serpentine,
  77. uint8_t octaves, uint16_t x, int xscale, uint16_t y, int yscale, uint16_t time,
  78. uint8_t hue_octaves, uint16_t hue_x, int hue_xscale, uint16_t hue_y, uint16_t hue_yscale,uint16_t hue_time,bool blend);
  79. void fill_2dnoise16(CRGB *leds, int width, int height, bool serpentine,
  80. uint8_t octaves, uint32_t x, int xscale, uint32_t y, int yscale, uint32_t time,
  81. uint8_t hue_octaves, uint16_t hue_x, int hue_xscale, uint16_t hue_y, uint16_t hue_yscale,uint16_t hue_time, bool blend, uint16_t hue_shift=0);
  82. FASTLED_NAMESPACE_END
  83. ///@}
  84. #endif