‹ pakt16pakt18 ›

pakt17

See /software/p5js/pakt-februari/pakt17/ for a JavaScript version and /software/supercollider/februari-pakt/pakt17/ 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 pakt17App : public App {
public:
  void setup();
  void draw();
  int index;
  float w, h;
  float a, b, c, d;
  float spread;
  int n;
};

void pakt17App::setup() {
  index= 0;
  w= getWindowWidth();
  h= getWindowHeight();
  n= 45;
}

void pakt17App::draw() {

  spread= sin(index*0.004f)*5.0f+6.0f;

  cairo::Context ctx(cairo::createWindowSurface());
  ctx.setSourceRgb(0.0, 0.0, 0.0);
  ctx.paint();
  //ctx.setLineWidth(15.0);
  for(int i= 0; i<n; i++) {
    a= sin(((i*spread)+index)*sin(index*0.0050+(sin(index*0.0074+1.0f)+1.0f))*0.0075f+1.0f)*0.25f+0.5f;
    b= sin(((i*spread)+index)*sin(index*0.0051+(sin(index*0.0073+2.0f)+2.0f))*0.0075f+2.0f)*0.25f+0.5f;
    c= sin(((i*spread)+index)*sin(index*0.0052+(sin(index*0.0072+3.0f)+3.0f))*0.0075f+3.0f)*0.25f+0.5f;
    d= sin(((i*spread)+index)*sin(index*0.0053+(sin(index*0.0071+4.0f)+4.0f))*0.0075f+4.0f)*0.25f+0.5f;
    ctx.setSourceRgba(a, b, c, d);
    ctx.rectangle(vec2(a*w, b*h), vec2(c*w, d*h));
    ctx.fill();
    //ctx.stroke();
  }
  index++;
}

CINDER_APP(pakt17App, Renderer2d, [&]( App::Settings *settings ) {
  settings->setWindowSize( WIDTH, HEIGHT );
  settings->setResizable( false );
})