pakt15

#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 pakt15App : public AppBasic {
public:
void prepareSettings(Settings *settings);
void setup();
void draw();
int index;
float w, h;
float speed;
float n;
};

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

void pakt15App::setup() {
index= 0;
w= getWindowWidth();
h= getWindowHeight();
n= 80.0f;
speed= 0.005f;
}

void pakt15App::draw() {

cairo::Context ctx= cairo::Context(cairo::createWindowSurface());

ctx.setSourceRgb(0.0, 0.0, 0.0);
ctx.paint();

ctx.setLineWidth(1.0);
ctx.translate(Vec2f(w*0.5f, h*0.5f));
for(int i= 0; i<=n; i++) {
ctx.setSourceRgba(1, sin((index+i)*0.1)*0.5+0.5, 1.0, 0.5);
ctx.rotate(i/n*M_PI*2+(index*sin(index*speed)*0.0001f));
ctx.moveTo(sin((index*0.1f)+(i*0.3f))*(h*0.3f), 0.0f);
ctx.lineTo(Vec2f(w*(sin((index+i)*0.0144f)*0.03f+0.26f), h*(cos((index+i)*0.0126f)*0.03f+0.26f)));
ctx.lineTo(Vec2f(w*(sin((index+i)*0.0244f)*0.02f+0.07f), h*(cos((index+i)*0.0226f)*0.02f+0.07f)));
ctx.stroke();
}
index++;
}

CINDER_APP_BASIC(pakt15App, Renderer2d)