pakt11

#include "cinder/app/AppBasic.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 pakt11App : public AppBasic {
public:
void prepareSettings(Settings *settings);
void setup();
void draw();
int index, n;
float rowsMid, colsMid, rows, cols, w, h;
cairo::Context ctx;
};

void pakt11App::prepareSettings(Settings *settings) {
settings->setWindowSize(WIDTH, HEIGHT);
settings->setResizable(false);
}

void pakt11App::setup() {
index= 0;
rowsMid= 22.0f;
colsMid= 20.0f;
w= getWindowWidth();
h= getWindowHeight();
ctx= cairo::Context(cairo::createWindowSurface());
ctx.scale(0.96f, 0.96f);
ctx.translate(5.0f, 5.0f);
}

void pakt11App::draw() {

rows= rowsMid+(sin(index*0.0015)*10.0f);
cols= colsMid+(sin(index*0.0024)*10.0f);

cairo::GradientRadial radialGrad(getWindowCenter(), 0, getWindowCenter(), getWindowWidth());
radialGrad.addColorStop(0, Color(0.6, 0.5, 0.5));
radialGrad.addColorStop(1, Color(0, 0, 0));
ctx.setSource(radialGrad);
ctx.paint();

ctx.setSourceRgb(1, 1, 1);
ctx.moveTo(0, 0);
for(int x= 0; x<=rows; x++) {
for(int y= 0; y<=cols; y++) {
ctx.lineTo((x/rows*w)+sin(index+(x*y)*32.0f), (y/cols*h)+cos(index+(x*y)*24.0f));
ctx.lineTo((x/cols*w)+sin(index+(x*y)*32.0f), (y/rows*h)+cos(index+(x*y)*24.0f));
}
}
ctx.fill();
index++;
}

CINDER_APP_BASIC(pakt11App, Renderer2d)