pakt10
See /software/p5js/pakt-februari/pakt10/ for a JavaScript version and /software/supercollider/februari-pakt/pakt10/ for accompanying sound code.
#include "cinder/app/App.h"
#include "cinder/cairo/Cairo.h"
using namespace ci;
using namespace ci::app;
using namespace std;
const int WIDTH= 640;
const int HEIGHT= 480;
class pakt10App : public App {
public:
void setup();
void draw();
int index, n;
float rows, cols;
float rowMod, colMod;
float magic;
};
void pakt10App::setup() {
index= 0;
n= 1200;
rows= 11;
cols= 12;
rowMod= 2.0f;
colMod= 3.0f;
magic= 0.0f;
}
void pakt10App::draw() {
cairo::Context ctx(cairo::createWindowSurface());
float w= getWindowWidth();
float h= getWindowHeight();
float r= rows+(sin(index*0.013)*rowMod)+(sin(index*0.00133)*rowMod*0.56);
float c= cols+(cos(index*0.022)*colMod)+(cos(index*0.00122)*colMod*0.45);
cairo::GradientRadial radialGrad(getWindowCenter(), 0, getWindowCenter(), getWindowWidth());
radialGrad.addColorStop(0, Color(0.2, 0.2, 0.5));
radialGrad.addColorStop(1, Color(0, 0, 0));
ctx.setSource(radialGrad);
ctx.paint();
ctx.setSourceRgba(1, 1, 0.2, 0.85);
for(int i= 0; i<n; i++) {
vec2 p= vec2(fmod((r+i), w), fmod((c+i)*(fmod(i, magic+1.01f)), h));
ctx.moveTo(p);
ctx.lineTo(p+vec2(10*sin((index+i)*0.02), 10*cos((index+i)*0.03)));
}
ctx.stroke();
rows= rows+(sin(index*0.0004));
cols= cols+(sin(index*0.0005));
index++;
magic= fmod(magic+0.00002f, 15.0f);
}
CINDER_APP(pakt10App, Renderer2d, [&]( App::Settings *settings ) {
settings->setWindowSize( WIDTH, HEIGHT );
settings->setResizable( false );
})