Skip to content

Instantly share code, notes, and snippets.

@tonussi
Created March 13, 2013 17:13
Show Gist options
  • Save tonussi/5154200 to your computer and use it in GitHub Desktop.
Save tonussi/5154200 to your computer and use it in GitHub Desktop.
estudando vetores em processing.
int x, y;
void setup() {
size(800, 450);
background(255);
fill(0, 0, 100, 20);
strokeWeight(1.8);
stroke(0, 0, 100, 80);
}
void draw() {
background(255);
PVector p = PVector.random2D();
//p.add(new PVector(width/2, height/2));
p.add(pos());
//println(p.toString());
//println(update().toString());
ellipse(p.x, p.y, 120, 120);
line(p.x, p.y, p.x + 120/4, p.y + 120/4);
PVector m = new PVector((width/2 + 120/4) - p.x, (height/2 + 120/4) - p.y);
//rect(m.x, m.y, 10, 10);
}
PVector pos() {
if (mousePressed) {
return new PVector(random(width), random(height));
}
return new PVector(width/2, height/2);
}
PVector random2D() {
return new PVector(round(random(-1, 0)), round(random(-1, 0)), 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment