446 {
447
450
451
452 uint32_t now = millis();
453 uint16_t noise_z = now * noise_speed / 10;
454 uint16_t noise_x = now * noise_speed / 80;
455 uint16_t noise_y = now * noise_speed / 160;
456
459
460
461 uint8_t dataSmoothing = 0;
462 if(noise_speed < 50) {
463 dataSmoothing = 200 - (noise_speed * 4);
464 }
465
466
467 for(
int x = 0;
x < width;
x++) {
468 for(
int y = 0;
y < height;
y++) {
469
470
471 float angle = (float(
x) / float(width)) * 2.0f *
PI;
472
473
474
475 float cylinder_radius = noise_scale;
476
477
478 float noise_x_cyl = cos(angle) * cylinder_radius;
479 float noise_y_cyl = sin(angle) * cylinder_radius;
480 float noise_z_height = float(
y) * noise_scale;
481
482
483 int xoffset = int(noise_x_cyl) + noise_x;
484 int yoffset = int(noise_y_cyl) + noise_y;
485 int zoffset = int(noise_z_height) + noise_z;
486
487
488 uint8_t data =
inoise8(xoffset, yoffset, zoffset);
489
490
491 data =
qsub8(data, 16);
493
494
495 if(dataSmoothing) {
497 uint8_t olddata = (oldColor.r + oldColor.g + oldColor.b) / 3;
498 uint8_t newdata =
scale8(olddata, dataSmoothing) +
scale8(data, 256 - dataSmoothing);
499 data = newdata;
500 }
501
502
503 uint8_t index = data;
504 uint8_t bri = data;
505
506
507 uint8_t ihue = 0;
509 ihue = (now / 100) % 256;
510 index += ihue;
511 }
512
513
514
515
516
517
518
519
520
522
523
527
529 }
530 }
531}
UIDropdown luminanceFunction("Luminance Function", easeOptions)
UIDropdown saturationFunction("Saturation Function", easeOptions)
UISlider noiseScale("Noise Scale", 100, 10, 200, 5)
fl::shared_ptr< Grid< CRGB > > frameBufferPtr
UISlider noiseSpeed("Noise Speed", 4, 1, 100, 1)
CRGBPalette16 noisePalette
EaseType getEaseType(fl::string value)
LIB8STATIC_ALWAYS_INLINE uint8_t qadd8(uint8_t i, uint8_t j)
Add one byte to another, saturating at 0xFF.
LIB8STATIC_ALWAYS_INLINE uint8_t qsub8(uint8_t i, uint8_t j)
Subtract one byte from another, saturating at 0x00.
uint8_t inoise8(uint16_t x, uint16_t y, uint16_t z)
8-Bit, fixed point implementation of Perlin's noise.
LIB8STATIC_ALWAYS_INLINE uint8_t scale8(uint8_t i, fract8 scale)
Scale one byte by a second one, which is treated as the numerator of a fraction whose denominator is ...
CRGB ColorFromPalette(const CRGBPalette16 &pal, fl::u8 index, fl::u8 brightness, TBlendType blendType)
CRGB colorBoost(fl::EaseType saturation_function=fl::EASE_NONE, fl::EaseType luminance_function=fl::EASE_NONE) const
Representation of an RGB pixel (Red, Green, Blue)