domingo, 10 de maio de 2009

Processing - 2° Trabalho

Esse é o meu segundo trabalho no Processing e introduz a interação com o mouse (as linhas novas são formadas de acordo com a posição do mouse).



código fonte:

float a = 0.0;
float _strokeCol = 254;
float x = 0.0;
float y = 0.0;
float atraso = 0.05;

void setup() {
size(800, 600, P3D);
smooth();
frameRate(30);
background(190,230,255);
}

void draw(){
pushMatrix();
float targetX = mouseX;
float targetY = mouseY;
x += (targetX - x) * atraso;
y += (targetY - y) * atraso;
translate(x,y-50);
a = a + .01;
float n = noise(a) * width;
rotateZ(a * PI);
_strokeCol += _strokeChange;
if (_strokeCol > 254) { _strokeChange *= -1; }
if (_strokeCol < 0) { _strokeChange *= -1; }
stroke((_strokeCol)-10,(_strokeCol)+70,(_strokeCol)+200,(_strokeCol)/2+130);
strokeWeight(1);
line(0, 0, 0, n);
popMatrix();
}
int _strokeChange = -1;

Nenhum comentário:

Postar um comentário