Moved all individual effects into a subfolder {src,include}/effects/
This commit is contained in:
65
src/effects/sinematrix3.cpp
Normal file
65
src/effects/sinematrix3.cpp
Normal file
@ -0,0 +1,65 @@
|
||||
#include "effects/sinematrix3.h"
|
||||
#include "prototypes.h"
|
||||
#include "functions.h"
|
||||
#include "Effect.h"
|
||||
#include "my_color_palettes.h"
|
||||
|
||||
boolean Sinematrix3Effect::can_be_shown_with_clock() { return true; };
|
||||
void Sinematrix3Effect::loop(uint16_t ms) {
|
||||
pangle = addmodpi( pangle, 0.0133 + (angle / 256) );
|
||||
angle = cos(pangle) * PI;
|
||||
sx = addmodpi( sx, 0.00673 );
|
||||
sy = addmodpi( sy, 0.00437 );
|
||||
tx = addmodpi( tx, 0.00239 );
|
||||
ty = addmodpi( ty, 0.00293 );
|
||||
cx = addmodpi( cx, 0.00197 );
|
||||
cy = addmodpi( cy, 0.00227 );
|
||||
rcx = (LED_WIDTH / 2) + (sin(cx) * LED_WIDTH);
|
||||
rcy = (LED_HEIGHT / 2) + (sin(cy) * LED_HEIGHT);
|
||||
angle2 = addmodpi( angle2, 0.0029 );
|
||||
sx2 = addmodpi( sx2, 0.0041);
|
||||
sy2 = addmodpi( sy2, 0.0031);
|
||||
tx2 = addmodpi( tx2, 0.0011 );
|
||||
ty2 = addmodpi( ty2, 0.0023 );
|
||||
basecol = addmod( basecol, 1.0, 0.007 );
|
||||
|
||||
rotate = {
|
||||
.a11 = cos(angle),
|
||||
.a12 = -sin(angle),
|
||||
.a21 = sin(angle),
|
||||
.a22 = cos(angle)
|
||||
};
|
||||
Matrix zoom = {
|
||||
.a11 = sin(sx) / 4.0 + 0.15,
|
||||
.a12 = 0, //atan(cos(sx2)),
|
||||
.a21 = 0, //atan(cos(sy2)),
|
||||
.a22 = cos(sy) / 4.0 + 0.15
|
||||
};
|
||||
Vector translate = {
|
||||
.x1 = sin(tx) * LED_WIDTH,
|
||||
.x2 = sin(ty) * LED_HEIGHT
|
||||
};
|
||||
|
||||
for ( int x = 0; x < LED_WIDTH; x++ ) {
|
||||
for ( int y = 0; y < LED_HEIGHT; y++ ) {
|
||||
Vector c = add(multiply( multiply(rotate, zoom), { .x1 = x - rcx, .x2 = y - rcy } ), translate);
|
||||
int sat = (basecol + basefield(c.x1, c.x2)) * 255;
|
||||
CRGB color(_get_color(sat));
|
||||
window->setPixel(x, y, &color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CRGB Sinematrix3Effect::_get_color(int sat) {
|
||||
switch(_color_scheme) {
|
||||
case SINEMATRIX_COLOR_PASTEL_RAINBOW: return CRGB(CHSV(sat, 120, 255));
|
||||
case SINEMATRIX_COLOR_RAINBOW: return CRGB(CHSV(sat, 255, 255));
|
||||
case SINEMATRIX_COLOR_PURPLEFLY: return ColorFromPalette((CRGBPalette16)palette_purplefly_gp, (uint8_t)sat);
|
||||
}
|
||||
return CRGB(0xFF00FF);
|
||||
}
|
||||
|
||||
boolean Sinematrix3Effect::clock_as_mask() {
|
||||
if (_color_scheme == SINEMATRIX_COLOR_PASTEL_RAINBOW) return true;
|
||||
return false;
|
||||
};
|
Reference in New Issue
Block a user