pakt20
See /software/p5js/pakt-februari/pakt20/ for a JavaScript version and /software/supercollider/februari-pakt/pakt20/ 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 pakt20App : public App {
public:
void setup();
void draw();
cairo::SurfaceImage srfOff;
cairo::Context ctxOff;
int index, n;
float w, h;
float spread;
};
void pakt20App::setup() {
srfOff= cairo::SurfaceImage(WIDTH, HEIGHT, false);
ctxOff= cairo::Context(srfOff);
ctxOff.setSourceRgb(0, 0, 0);
ctxOff.paint();
ctxOff.setLineWidth(1);
ctxOff.setAntiAlias(0);
index= 0;
w= getWindowWidth();
h= getWindowHeight();
n= 150;
}
void pakt20App::draw() {
cairo::Context ctx(cairo::createWindowSurface());
spread= sin(index*0.002f);
for(int i= 0; i<n; i++) {
float tx= sin(0.012f*(index+(i*spread)));
float ty= sin(0.014f*(index+(i*spread)));
float tz= sin(0.016f*(index+(i*spread)))*0.5f+0.5f;
ctxOff.setSourceRgba(tz, tz*0.9f, tz, 0.05f);
ctxOff.moveTo(vec2(sin(tx+sin(index*0.001f))*(sin(tx)*0.001f+1.0f)*w*0.46f+(w*0.5f), sin(ty+cos(index*0.001f*i))*(cos(ty)*0.001f+1.0f)*h*0.46f+(h*0.5f)));
ctxOff.lineTo(vec2(cos(ty+sin(index*0.001f))*(sin(tx)*0.001f+1.0f)*w*0.36f+(w*0.5f), sin(tx+cos(index*0.001f*i))*(cos(ty)*0.001f+1.0f)*h*0.36f+(h*0.5f)));
ctxOff.stroke();
}
index++;
ctx.copySurface(srfOff, srfOff.getBounds());
}
CINDER_APP(pakt20App, Renderer2d, [&]( App::Settings *settings ) {
settings->setWindowSize( WIDTH, HEIGHT );
settings->setResizable( false );
})