#include "effect_sinematrix3.h" #include "prototypes.h" #include "functions.h" #include "Effect.h" boolean Sinematrix3Effect::can_be_shown_with_clock() { return true; }; boolean Sinematrix3Effect::clock_as_mask() { return true; }; void Sinematrix3Effect::loop() { 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; setPixel(window, x, y, CHSV(sat, 120, 255)); } } }