pakt16
See /software/p5js/pakt-februari/pakt16/ for a JavaScript version and /software/supercollider/februari-pakt/pakt16/ 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 pakt16App : public App {
public:
void setup();
void draw();
int index;
float w, h;
float radius1, radius2, radius3;
float ex1, ex2, ex3;
float n;
};
void pakt16App::setup() {
index= 0;
w= getWindowWidth();
h= getWindowHeight();
}
void pakt16App::draw() {
radius1= sin(index*0.013)*0.3f+0.1f;
radius2= sin(index*0.021)*0.2f+0.25f;
radius3= sin(index*0.012)*0.1f+0.4f;
ex1= sin(index*0.0052)*3.0f+3.0f;
ex2= sin(index*0.0061)*6.0f+6.0f;
ex3= sin(index*0.0053)*2.0f+2.0f;
n= sin(index*0.001f)*40+50;
cairo::Context ctx(cairo::createWindowSurface());
ctx.setSourceRgb(0.0, 0.0, 0.0);
ctx.paint();
ctx.setLineWidth(1.0);
ctx.translate(vec2(w*0.5f, h*0.5f));
for(int i= 0; i<n; i++) {
float t= (i/n)*M_PI*2;
ctx.setSourceRgba(1, 1, 1,sin((index+(i*sin(index*0.008f+(i*sin(index*0.013f)*0.01f))*2.0f))*0.1f)*0.5+0.5);
//ctx.rotate(t+(index*sin(index*0.005f)*0.0001f));
ctx.moveTo(sin(t+ex1)*radius1*w, cos(t+ex1)*radius1*h);
ctx.quadTo(vec2(sin(t+ex2)*radius2*w, cos(t+ex2)*radius2*h), vec2(sin(t+ex3)*radius3*w, cos(t+ex3)*radius3*h));
ctx.stroke();
}
index++;
}
CINDER_APP(pakt16App, Renderer2d, [&]( App::Settings *settings ) {
settings->setWindowSize( WIDTH, HEIGHT );
settings->setResizable( false );
})