pakt07
See /software/p5js/pakt-februari/pakt07/ for a JavaScript version and /software/supercollider/februari-pakt/pakt07/ 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 pakt07App : public App {
public:
void setup();
void draw();
int n;
float w, h;
float theta, speed, spread;
vector<vec2> points;
};
void pakt07App::setup() {
n= 30;
theta= 0;
speed= 0.00002;
spread= 1;
for(int i= 0; i<n; i++) {
points.push_back(getWindowCenter());
}
w= getWindowWidth();
h= getWindowHeight();
}
void pakt07App::draw() {
cairo::Context ctx(cairo::createWindowSurface());
//ctx.setAntiAlias(1);
ctx.setFillRule(1);
ctx.setSourceRgb(0, 0, 0);
ctx.paint();
ctx.setSourceRgb(1.0f, 0, 0);
for(size_t i= 0; i<points.size(); i++) {
float x= (points[i].x/w)*2-1;
float y= (points[i].y/h)*2-1;
vec2 v= vec2(
(((cos(theta+(i*0.001))*x)-(sin(theta+(i*0.001))*y))*0.5+0.5)*w+spread,
(((cos(theta+(i*0.001))*y)+(sin(theta+(i*0.001))*x))*0.5+0.5)*h+spread
);
points[i]= v;
ctx.circle(v, 50);
theta= theta+speed;
}
ctx.fill();
}
CINDER_APP(pakt07App, Renderer2d, [&]( App::Settings *settings ) {
settings->setWindowSize( WIDTH, HEIGHT );
settings->setResizable( false );
})