Spectroscopic Processing applet

Some Processing code I scribbled together. With a pair of 3D-glasses it actually looks really good.

float rotx = 0, roty = 0;
void drawSpectroscopicSphere(float x, float y, float r, float rotx, float roty)
{
    noFill();

    // Draw left eye
    pushMatrix();
    translate(x-10, y, r);
    rotateX(roty);
    rotateY(rotx);
    stroke(255,0,0);
    sphere(140);
    popMatrix();

    // Draw right eye
    pushMatrix();
    translate(x+10, y, r);
    rotateX(roty);
    rotateY(rotx);
    stroke(0,120,255);
    sphere(140);
    popMatrix();
}

void setup() {
    size(1000, 1000, P3D);
}

void draw()
{
    background(0);
    rotx = 0.95*rotx + 0.01*(mouseX/(TWO_PI*TWO_PI));
    roty = 0.95*roty - 0.01*((mouseY-width/2)/(TWO_PI*TWO_PI));
    drawSpectroscopicSphere(height/2, width/2, min(width,height)/2, rotx, roty);
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s