1#ifndef DISTORTION_WAVE_MODE_H
2#define DISTORTION_WAVE_MODE_H
6#include "src/system/ext/math8.h"
7#include "src/system/ext/noise.h"
30 static void on_enter_mode(
auto& ctx)
32 ctx.state.speed = 128;
33 ctx.state.scale = 128;
36 static void loop(
auto& ctx)
38 const uint8_t _speed = ctx.state.speed / 32;
39 const uint8_t _scale = ctx.state.scale / 32;
43 const uint16_t a = ctx.lamp.tick / 2;
44 const uint16_t a2 = a / 2;
45 const uint16_t a3 = a / 3;
47 const uint16_t cx = beatsin8(10 - _speed, 0, ctx.lamp.maxWidth) * _scale;
48 const uint16_t cy = beatsin8(12 - _speed, 0, ctx.lamp.maxHeight - 1) * _scale;
49 const uint16_t cx1 = beatsin8(13 - _speed, 0, ctx.lamp.maxWidth) * _scale;
50 const uint16_t cy1 = beatsin8(15 - _speed, 0, ctx.lamp.maxHeight - 1) * _scale;
51 const uint16_t cx2 = beatsin8(17 - _speed, 0, ctx.lamp.maxWidth) * _scale;
52 const uint16_t cy2 = beatsin8(14 - _speed, 0, ctx.lamp.maxHeight - 1) * _scale;
55 for (
int x = 0; x <= ctx.lamp.maxWidth; x++)
60 for (
int y = 0; y <= ctx.lamp.maxHeight; y++)
64 const uint8_t rdistort = cos8((cos8(((x << 3) + a) & 255) + cos8(((y << 3) - a2) & 255) + a3) & 255) >> 1;
65 const uint8_t gdistort = cos8((cos8(((x << 3) - a2) & 255) + cos8(((y << 3) + a3) & 255) + a + 32) & 255) >> 1;
66 const uint8_t bdistort = cos8((cos8(((x << 3) + a3) & 255) + cos8(((y << 3) - a) & 255) + a2 + 64) & 255) >> 1;
68 const uint8_t red = rdistort + w * (a - (((xoffs - cx) * (xoffs - cx) + (yoffs - cy) * (yoffs - cy)) >> 7));
70 gdistort + w * (a2 - (((xoffs - cx1) * (xoffs - cx1) + (yoffs - cy1) * (yoffs - cy1)) >> 7));
72 bdistort + w * (a3 - (((xoffs - cx2) * (xoffs - cx2) + (yoffs - cy2) * (yoffs - cy2)) >> 7));
74 ctx.lamp.setPixelColorXY(x,
Define the gamma color correction.
static constexpr LMBD_INLINE uint32_t fromRGB(uint8_t r, uint8_t g, uint8_t b)
Return color (r, g, b) as a single uint32_t integer.
Definition: utils.hpp:24
static constexpr uint8_t gamma8(uint8_t value)
used for color gamma correction
Definition: gamma.hpp:43
Basic "default" modes included with the hardware.
Definition: aurora.hpp:12
Parent object for all custom user modes.
Definition: mode_type.hpp:53
Definition: distortion_waves.hpp:23
uint16_t speed
animation speed
Definition: distortion_waves.hpp:25
uint16_t scale
animation scale
Definition: distortion_waves.hpp:27
Emulate color circle waves propagating. Distortion waves - ldirko. https://editor....
Definition: distortion_waves.hpp:21