pakt10
Submitted by f0 on Sun, 2011-02-27 21:09
#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 pakt10App : public AppBasic {
public:
void prepareSettings(Settings *settings);
void setup();
void draw();
int index, n;
float rows, cols;
float rowMod, colMod;
float magic;
cairo::Context ctx;
};
void pakt10App::prepareSettings(Settings *settings) {
settings->setWindowSize(WIDTH, HEIGHT);
settings->setResizable(false);
}
void pakt10App::setup() {
index= 0;
n= 1200;
rows= 11;
cols= 12;
rowMod= 2.0f;
colMod= 3.0f;
magic= 0.0f;
ctx= cairo::Context(cairo::createWindowSurface());
}
void pakt10App::draw() {
float w= getWindowWidth();
float h= getWindowHeight();
float r= rows+(sin(index*0.013)*rowMod)+(sin(index*0.00133)*rowMod*0.56);
float c= cols+(cos(index*0.022)*colMod)+(cos(index*0.00122)*colMod*0.45);
cairo::GradientRadial radialGrad(getWindowCenter(), 0, getWindowCenter(), getWindowWidth());
radialGrad.addColorStop(0, Color(0.2, 0.2, 0.5));
radialGrad.addColorStop(1, Color(0, 0, 0));
ctx.setSource(radialGrad);
ctx.paint();
ctx.setSourceRgba(1, 1, 0.2, 0.85);
for(int i= 0; i<n; i++) {
Vec2f p= Vec2f(fmod((r+i), w), fmod((c+i)*(fmod(i, magic+1.01f)), h));
ctx.moveTo(p);
ctx.lineTo(p+Vec2f(10*sin((index+i)*0.02), 10*cos((index+i)*0.03)));
}
ctx.stroke();
rows= rows+(sin(index*0.0004));
cols= cols+(sin(index*0.0005));
index++;
magic= fmod(magic+0.00002f, 15.0f);
}
CINDER_APP_BASIC(pakt10App, Renderer2d)
#include "cinder/cairo/Cairo.h"
using namespace ci;
using namespace ci::app;
using namespace std;
const int WIDTH= 640;
const int HEIGHT= 480;
class pakt10App : public AppBasic {
public:
void prepareSettings(Settings *settings);
void setup();
void draw();
int index, n;
float rows, cols;
float rowMod, colMod;
float magic;
cairo::Context ctx;
};
void pakt10App::prepareSettings(Settings *settings) {
settings->setWindowSize(WIDTH, HEIGHT);
settings->setResizable(false);
}
void pakt10App::setup() {
index= 0;
n= 1200;
rows= 11;
cols= 12;
rowMod= 2.0f;
colMod= 3.0f;
magic= 0.0f;
ctx= cairo::Context(cairo::createWindowSurface());
}
void pakt10App::draw() {
float w= getWindowWidth();
float h= getWindowHeight();
float r= rows+(sin(index*0.013)*rowMod)+(sin(index*0.00133)*rowMod*0.56);
float c= cols+(cos(index*0.022)*colMod)+(cos(index*0.00122)*colMod*0.45);
cairo::GradientRadial radialGrad(getWindowCenter(), 0, getWindowCenter(), getWindowWidth());
radialGrad.addColorStop(0, Color(0.2, 0.2, 0.5));
radialGrad.addColorStop(1, Color(0, 0, 0));
ctx.setSource(radialGrad);
ctx.paint();
ctx.setSourceRgba(1, 1, 0.2, 0.85);
for(int i= 0; i<n; i++) {
Vec2f p= Vec2f(fmod((r+i), w), fmod((c+i)*(fmod(i, magic+1.01f)), h));
ctx.moveTo(p);
ctx.lineTo(p+Vec2f(10*sin((index+i)*0.02), 10*cos((index+i)*0.03)));
}
ctx.stroke();
rows= rows+(sin(index*0.0004));
cols= cols+(sin(index*0.0005));
index++;
magic= fmod(magic+0.00002f, 15.0f);
}
CINDER_APP_BASIC(pakt10App, Renderer2d)