Monday, May 5, 2008

A Basic Scroll Example

Hack this. But cut and paste first to figure out what is what...note, the pmouseX and the pmouseY. You have some examples from earlier to help you out with this. Dig them up....

///Code is as follows:

float x = 0;
float y = 0;

void setup(){
size(400, 400);
noStroke();
}


void draw(){
background(0);

beginShape();
vertex(20 + x, 20 + y);
vertex(40 + x, 20 + y);
vertex(40 + x, 40 + y);
vertex(60 + x, 40 + y);
vertex(60 + x, 60 + y);
vertex(20 + x, 60 + y);
endShape(CLOSE);
}




void mouseDragged()
{
x +=(mouseX-pmouseX);
y +=(mouseY-pmouseY);
}

No comments: