Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void setup() {
- size(600, 600);
- noStroke();
- }
- void draw() {
- background(255);
- float x = mouseX-width/2;
- float y = mouseY-height/2;
- float[] vA = new float[2];
- float[] vB = new float[2];
- vA = coordenadasPolares(atan2(y, x), 20);
- vB = coordenadasPolares(atan2(y, x), 30);
- if (distancia2D(width/2, mouseX, height/2, mouseY) > 50) {
- fill(30, 170, 18);
- ellipse(width/2, height/2, 140, 140);
- fill(0);
- ellipse(vB[0]+ width/2, vB[1]+ height/2, 40, 40);
- } else {
- fill(30, 170, 18);
- ellipse(width/2, height/2, 140, 140);
- fill(0);
- ellipse(mouseX, mouseY, 40, 40);
- }
- }
- float distancia2D(float x1, float x2, float y1, float y2) {
- float d = sqrt(pow((x2-x1), 2) + pow((y2-y1), 2));
- return d;
- }
- float[] coordenadasPolares(float ang, float raio) {
- float vC[] = new float[2];
- vC[0] = raio*cos( (ang));
- vC[1] = raio*sin( (ang));
- return vC;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement