Skip to content

Instantly share code, notes, and snippets.

Created June 18, 2014 14:01
Show Gist options
  • Save anonymous/bcc82542335778333a0a to your computer and use it in GitHub Desktop.
Save anonymous/bcc82542335778333a0a to your computer and use it in GitHub Desktop.

Revisions

  1. @invalid-email-address Anonymous created this gist Jun 18, 2014.
    71 changes: 71 additions & 0 deletions gistfile1.pde
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,71 @@
    int[][] result;
    float time;

    void setup() {
    setup_();
    result = new int[width*height][3];
    }

    void draw() {
    for (int i=0; i<width*height; i++)
    for (int a=0; a<3; a++)
    result[i][a] = 0;

    for (int sa=0; sa<samplesPerFrame; sa++) {
    time = map(frameCount-1 + sa*shutterAngle/samplesPerFrame, 0, numFrames, 0, 1);
    draw_();
    loadPixels();
    for (int i=0; i<pixels.length; i++) {
    result[i][0] += pixels[i] >> 16 & 0xff;
    result[i][1] += pixels[i] >> 8 & 0xff;
    result[i][2] += pixels[i] & 0xff;
    }
    }

    loadPixels();
    for (int i=0; i<pixels.length; i++)
    pixels[i] = 0xff << 24 | (result[i][0]/samplesPerFrame) << 16 |
    (result[i][1]/samplesPerFrame) << 8 | (result[i][2]/samplesPerFrame);
    updatePixels();

    saveFrame("f###.gif");
    if (frameCount==numFrames)
    exit();
    }

    //////////////////////////////////////////////////////////////////////////////

    int samplesPerFrame = 64;
    int numFrames = 150;
    float shutterAngle = .8;

    void setup_() {
    size(500,500);
    smooth(4);
    noStroke();
    rectMode(CENTER);
    }

    float w = 6.5, h = 150;
    float t;
    float pp = .08;
    float sc;

    // by dave @ beesandbombs.tumblr.com

    void draw_() {
    t = time + 4;
    background(255,0,0);
    pushMatrix();
    translate(width/2,height/2);
    for(int i=0; i<12; i++){
    fill(255*((i+20)%2));
    pushMatrix();
    rotate(QUARTER_PI*i + HALF_PI*t);
    sc = 0.0001*pow(pp,i-2*t);
    rect(0,0,w*sc,h*sc);
    rect(0,0,h*sc,w*sc);
    popMatrix();
    }
    popMatrix();
    }