‹ pakt12pakt14 ›

pakt13

See /software/p5js/pakt-februari/pakt13/ for a JavaScript version and /software/supercollider/februari-pakt/pakt13/ 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 pakt13App : public App {
public:
    void setup();
    void draw();
    int index, n;
    float w, h;
    float rows, cols;
};
void pakt13App::setup() {
    index= 0;
    w= getWindowWidth();
    h= getWindowHeight();
    rows= 11.0f;
    cols= 11.0f;
}
void pakt13App::draw() {
    cairo::Context ctx(cairo::createWindowSurface());
    ctx.setFillRule(1);
    cairo::GradientRadial radialGrad(getWindowCenter(), 0, getWindowCenter(), getWindowWidth());
    radialGrad.addColorStop(0, Color(0.5, 0.6, 0.5));
    radialGrad.addColorStop(1, Color(0, 0, 0));
    ctx.setSource(radialGrad);
    ctx.paint();
    ctx.setSourceRgb(1, 1, 1);
    for(int y= 0; y<=rows; y++) {
        for(int x= 0; x<=cols; x++) {
            ctx.rectangle(Rectf((x/rows*w)+(sin(index+(x*y))*(sin((index+x)*0.0015f)+sin((index+y)*0.0062)*10.0f)), (y/cols*h)+(cos(index+(x*y))*(sin((index+y)*0.0325f)+sin((index+y)*0.0072)*10.0f)), 4.0f, 4.0f));
        }
    }
    ctx.fill();
    index++;
}
CINDER_APP(pakt13App, Renderer2d, [&]( App::Settings *settings ) {
    settings->setWindowSize( WIDTH, HEIGHT );
    settings->setResizable( false );
})