Created
March 13, 2013 17:13
-
-
Save tonussi/5154200 to your computer and use it in GitHub Desktop.
estudando vetores em processing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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